JSPM

shallow-equals

1.0.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 213224
  • Score
    100M100P100Q184320F
  • License MIT

Determine if an array or object is equivalent with another, *not* recursively

Package Exports

  • shallow-equals

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (shallow-equals) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

shallow-equals Flattr this!experimental

Determine if an array or object is equivalent with another, not recursively.

Usage

shallow-equals

equals(a, b, [compare])

Check if a and b are pretty much the same thing. Note this won't be the case if a and b are different types (e.g. Array vs. Object, String vs. Function).

By default, all comparisons between values are using the strict equality (===) operator. You can also pass in a custom compare function to override this behavior.

var equals = require('shallow-equals')

// true:
equals([1, 2, 3], [1, 2, 3])

// true:
equals({ hello: 'world' }, { hello: 'world' })

// false:
equals([1, 2, {}], [1, 2, {}])

// true:
equals([1, 2], [
  { value: 1 },
  { value: 2 }
], function(a, b) {
  return a === b.value
})

License

MIT. See LICENSE.md for details.