Buckets:
6.69 GB
45,738 files
Updated about 2 months ago
Ctrl+K
| Name | Size | Uploaded | Xet hash |
|---|---|---|---|
| umd | 2 items | ||
| esm | 1 items | ||
| cjs | 2 items | ||
| package.json | 904 Bytes xet | 8958230e | |
| index.js | 179 Bytes xet | 76e9b470 | |
| README.md | 1.72 kB xet | eee2cb16 | |
| LICENSE | 1.08 kB xet | d1299f3d |
value-equal
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.statevalues- 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!
- Total size
- 6.69 GB
- Files
- 45,738
- Last updated
- Sep 12
- Pre-warmed CDN
- US EU US EU