Socket
Socket
Sign inDemoInstall

value-equal

Package Overview
Dependencies
0
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    value-equal

Are these two JavaScript values equal?


Version published
Weekly downloads
4.1M
decreased by-2.31%
Maintainers
1
Install size
8.71 kB
Created
Weekly downloads
 

Readme

Source

value-equal Travis npm package

value-equal determines if two JavaScript values are equal using Object.prototype.valueOf.

In many instances when I'm checking for object equality, what I really want to know is if their values are equal. This is good for:

  • Stuff you keep in localStorage
  • window.history.state values
  • Query strings

Installation

Using npm:

$ npm install --save value-equal

Then with a module bundler like webpack, use as you would anything else:

// using ES6 modules
import valueEqual from 'value-equal';

// using CommonJS modules
var valueEqual = require('value-equal');

The UMD build is also available on unpkg:

<script src="https://unpkg.com/value-equal"></script>

You can find the library on window.valueEqual.

Usage

valueEqual(1, 1); // true
valueEqual('asdf', 'asdf'); // true
valueEqual('asdf', new String('asdf')); // true
valueEqual(true, true); // true
valueEqual(true, false); // false
valueEqual({ a: 'a' }, { a: 'a' }); // true
valueEqual({ a: 'a' }, { a: 'b' }); // false
valueEqual([1, 2, 3], [1, 2, 3]); // true
valueEqual([1, 2, 3], [2, 3, 4]); // false

That's it. Enjoy!

FAQs

Last updated on 03 Dec 2018

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