Skip to content

Commit

Permalink
Document diffJson() options (#332)
Browse files Browse the repository at this point in the history
* Document diffJson() options

* Tweaks: fix run-on sentences; backtick JSON.stringify; name the JSON.stringify parameter this is similar to

* Add full stop

* Correct docs about how stringifyReplacer & undefinedReplacement interact

---------

Co-authored-by: Mark Amery <markrobertamery@gmail.com>
  • Loading branch information
cincodenada and ExplodingCabbage authored Dec 18, 2023
1 parent 87dedb6 commit e0e960a
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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](#change-objects).

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.
* `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 (===).

Expand Down

0 comments on commit e0e960a

Please sign in to comment.