Skip to content

fix: ignore functions without mutating input objects - #233

Open
Shubham-Padkonde wants to merge 1 commit into
yahoo:mainfrom
Shubham-Padkonde:fix/ignore-functions-without-mutation
Open

Shubham-Padkonde wants to merge 1 commit into
yahoo:mainfrom
Shubham-Padkonde:fix/ignore-functions-without-mutation

Conversation

@Shubham-Padkonde

Copy link
Copy Markdown

Using ignoreFunction: true currently deletes function-valued properties from the input object. Besides modifying caller-owned data, this throws for frozen objects and turns functions in dense arrays into holes rather than the null values produced by JSON.stringify.

Let JSON.stringify handle function values returned by the replacer instead of deleting properties. This preserves the documented JSON-like behavior of ignoreFunction while retaining the original objects and arrays.

Three regression tests fail before the fix: nested-object mutation, frozen objects, and functions in arrays. All 103 tests pass afterward (node --test test/unit/*.js), and git diff --check passes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant