Socket
Socket
Sign inDemoInstall

shallow-equals

Package Overview
Dependencies
0
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    shallow-equals

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


Version published
Maintainers
1
Install size
7.34 kB
Created

Readme

Source

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.

Keywords

FAQs

Last updated on 12 Feb 2017

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc