From df20e2a3a15d0123de52f9197a55b8f5ebdd7d33 Mon Sep 17 00:00:00 2001 From: Joel Bradshaw Date: Mon, 25 Oct 2021 12:24:55 -0700 Subject: [PATCH 1/4] Document diffJson() options --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index be7b4ec8a..7c8c312fc 100644 --- a/README.md +++ b/README.md @@ -56,6 +56,10 @@ npm install diff --save * `Diff.diffJson(oldObj, newObj[, options])` - diffs two JSON objects, comparing the fields defined on each. The order of fields, etc does not matter in this comparison. Returns a list of change objects (See below). + + Options + * `stringifyReplacer`: A custom replacer function, operates similarly to the parameter to [JSON.stringify()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify#the_replacer_parameter), but must be a function. `undefined` will _not_ be replaced by this function, see the next option + * `undefinedReplacement`: A value to replace `undefined` with. By default it will not be replaced, and replacements for `undefined` from `stringifyReplacer` will not be used. * `Diff.diffArrays(oldArr, newArr[, options])` - diffs two arrays, comparing each item for strict equality (===). From efb61851101945e3f52e5ea95d65ae5b350ea6a5 Mon Sep 17 00:00:00 2001 From: Mark Amery Date: Mon, 18 Dec 2023 13:35:59 +0000 Subject: [PATCH 2/4] Tweaks: fix run-on sentences; backtick JSON.stringify; name the JSON.stringify parameter this is similar to --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 7c8c312fc..735b423b9 100644 --- a/README.md +++ b/README.md @@ -58,7 +58,7 @@ npm install diff --save Returns a list of change objects (See below). Options - * `stringifyReplacer`: A custom replacer function, operates similarly to the parameter to [JSON.stringify()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify#the_replacer_parameter), but must be a function. `undefined` will _not_ be replaced by this function, see the next option + * `stringifyReplacer`: A custom replacer function. Operates similarly to the `replacer` parameter to [`JSON.stringify()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify#the_replacer_parameter), but must be a function. `undefined` will _not_ be replaced by this function; see the next option * `undefinedReplacement`: A value to replace `undefined` with. By default it will not be replaced, and replacements for `undefined` from `stringifyReplacer` will not be used. * `Diff.diffArrays(oldArr, newArr[, options])` - diffs two arrays, comparing each item for strict equality (===). From 474fdbbc19654bcbb8a42b970aaf570fb1cc2c57 Mon Sep 17 00:00:00 2001 From: Mark Amery Date: Mon, 18 Dec 2023 13:36:46 +0000 Subject: [PATCH 3/4] Add full stop --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 735b423b9..3ea79a9ae 100644 --- a/README.md +++ b/README.md @@ -58,7 +58,7 @@ npm install diff --save Returns a list of change objects (See below). Options - * `stringifyReplacer`: A custom replacer function. Operates similarly to the `replacer` parameter to [`JSON.stringify()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify#the_replacer_parameter), but must be a function. `undefined` will _not_ be replaced by this function; see the next option + * `stringifyReplacer`: A custom replacer function. Operates similarly to the `replacer` parameter to [`JSON.stringify()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify#the_replacer_parameter), but must be a function. `undefined` will _not_ be replaced by this function; see the next option. * `undefinedReplacement`: A value to replace `undefined` with. By default it will not be replaced, and replacements for `undefined` from `stringifyReplacer` will not be used. * `Diff.diffArrays(oldArr, newArr[, options])` - diffs two arrays, comparing each item for strict equality (===). From 19d4e0c46bf08dfdfd25fd8ac06a7f33003350e6 Mon Sep 17 00:00:00 2001 From: Mark Amery Date: Mon, 18 Dec 2023 13:52:28 +0000 Subject: [PATCH 4/4] Correct docs about how stringifyReplacer & undefinedReplacement interact --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 3ea79a9ae..4083da60a 100644 --- a/README.md +++ b/README.md @@ -58,8 +58,8 @@ npm install diff --save Returns a list of change objects (See below). Options - * `stringifyReplacer`: A custom replacer function. Operates similarly to the `replacer` parameter to [`JSON.stringify()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify#the_replacer_parameter), but must be a function. `undefined` will _not_ be replaced by this function; see the next option. - * `undefinedReplacement`: A value to replace `undefined` with. By default it will not be replaced, and replacements for `undefined` from `stringifyReplacer` will not be used. + * `stringifyReplacer`: A custom replacer function. Operates similarly to the `replacer` parameter to [`JSON.stringify()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify#the_replacer_parameter), but must be a function. + * `undefinedReplacement`: A value to replace `undefined` with. Ignored if a `stringifyReplacer` is provided. * `Diff.diffArrays(oldArr, newArr[, options])` - diffs two arrays, comparing each item for strict equality (===).