Skip to content
This repository has been archived by the owner on Aug 31, 2018. It is now read-only.

Commit

Permalink
util,assert: expose util.isDeepStrictEqual()
Browse files Browse the repository at this point in the history
Provide `util.isDeepStrictEqual()` that works like
`assert.deepStrictEqual()` but returns a boolean rather than throwing an
error.

Several userland modules have needed this functionality and implemented
it independently. This functionality already exists in Node.js core, so
this exposes it for use by modules. Modules that have needed this
functionality include `lodash`, `concordance` (used by `ava`), and
`qunit`.

PR-URL: nodejs/node#16084
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Evan Lucas <evanlucas@me.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Reviewed-By: Ali Ijaz Sheikh <ofrobots@google.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
  • Loading branch information
Trott authored and addaleax committed Oct 26, 2017
1 parent 63efd04 commit ebe7caa
Show file tree
Hide file tree
Showing 7 changed files with 1,028 additions and 504 deletions.
2 changes: 1 addition & 1 deletion doc/api/assert.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ changes:
* `expected` {any}
* `message` {any}

Similar to `assert.deepEqual()` with the following exceptions:
Identical to [`assert.deepEqual()`][] with the following exceptions:

1. Primitive values besides `NaN` are compared using the [Strict Equality
Comparison][] ( `===` ). Set and Map values, Map keys and `NaN` are compared
Expand Down
16 changes: 16 additions & 0 deletions doc/api/util.md
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,21 @@ util.inspect.defaultOptions.maxArrayLength = null;
console.log(arr); // logs the full array
```

## util.isDeepStrictEqual(val1, val2)
<!-- YAML
added: REPLACEME
-->

* `val1` {any}
* `val2` {any}
* Returns: {string}

Returns `true` if there is deep strict equality between `val` and `val2`.
Otherwise, returns `false`.

See [`assert.deepStrictEqual()`][] for more information about deep strict
equality.

## util.promisify(original)
<!-- YAML
added: v8.0.0
Expand Down Expand Up @@ -1187,6 +1202,7 @@ Deprecated predecessor of `console.log`.
[`Buffer.isBuffer()`]: buffer.html#buffer_class_method_buffer_isbuffer_obj
[`Error`]: errors.html#errors_class_error
[`Object.assign()`]: https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Object/assign
[`assert.deepStrictEqual()`]: assert.html#assert_assert_deepstrictequal_actual_expected_message
[`console.error()`]: console.html#console_console_error_data_args
[`console.log()`]: console.html#console_console_log_data_args
[`util.inspect()`]: #util_util_inspect_object_options
Expand Down
Loading

0 comments on commit ebe7caa

Please sign in to comment.