Like lodash isEqualWith but for shallow equal.
Last updated a year ago by darthtrevino .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @react-dnd/shallowequal 
SYNC missed versions from official npm registry.

shallowequal Build Status Downloads npm version

shallowequal is like lodash's isEqual (v3.10.1) but for shallow (strict) equal.

shallowequal(value, other, [customizer], [thisArg])

Performs a shallow equality comparison between two values (i.e. value and other) to determine if they are equivalent.

The equality check returns true if value and other are already strictly equal, OR when all the following are true:

  • value and other are both objects with the same keys
  • For each key, the value in value and other are strictly equal (===)

If customizer (expected to be a function) is provided it is invoked to compare values. If customizer returns undefined (i.e. void 0), then comparisons are handled by the shallowequal function instead.

The customizer is bound to thisArg and invoked with three arguments: (value, other, key).

NOTE: Docs are (shamelessly) adapted from lodash's v3.x docs


$ yarn add shallowequal
# npm v5+
$ npm install shallowequal
# before npm v5
$ npm install --save shallowequal


const shallowequal = require("shallowequal");

const object = { user: "fred" };
const other = { user: "fred" };

object == other;
// → false

shallowequal(object, other);
// → true


Code for shallowEqual originated from https://github.com/gaearon/react-pure-render/ and has since been refactored to have the exact same API as lodash.isEqualWith (as of v4.17.4).



  • Lint: yarn lint
  • Test: yarn test
  • Pretty: yarn pretty
  • Prepare: yarn prepare



Current Tags

  • 2.0.0                                ...           latest (a year ago)

1 Versions

  • 2.0.0                                ...           a year ago
Maintainers (1)
Today 837
This Week 4,452
This Month 29,555
Last Day 1,085
Last Week 6,279
Last Month 44,378
Dependencies (0)
Dev Dependencies (5)
Dependents (1)

Copyright 2014 - 2017 © taobao.org |