Deep comparison between two values to determine if they are equivalent
- β‘ Multi runtime support (
Deno
,Node.js
and Browsers) - π Pure TypeScript and provides type definition
- β Rambda's all test case is passed
- π Universal module, providing
ES modules
andUMD
- π¦ Optimized, super slim size
- π TSDoc-style comments
declare const equal: <T, U extends T>(a: T, b: U) => boolean
Parameter | Description |
---|---|
a |
Any value |
b |
Any value |
=>
Return true
if the reference memory is the same or the property members and their values are the same
Equality is defined as the data structure and property values are equivalent.
Numerical equivalence is based on Same-value-zero.
That is, all of the following comparisons are considered equivalent.
equal(NaN, NaN) // true
equal(0, 0) // true
equal(+0, 0) // true
equal(-0, 0) // true
equal(+0, -0) // true
Browser is supporting since IE11.
The TypeScript version must be 4.1.0
or higher.
equal
provides multi platform modules.
import { equal } from "https://deno.land/x/equal/mod.ts";
equal([1, 2, 3], [1, 2, 3]); // true
import { equal } from "https://x.nest.land/equal/mod.ts";
equal([1, ['hello', ['world']], [1, ['hello', ['world']]); // true
NPM package name is
lauqe
.
npm i lauqe
or
yarn add lauqe
import { equal } from "lauqe";
equal(new Date('2000/1/1'), new Date('2000/1/1')); // true
const { equal } = require("lauqe");
equal(/hello/g, /hello/g); // true
<script type="module">
import { equal } from "https://unpkg.com/lauqe?module";
console.log(equal(() => {}, () => {}); // true
</script>
The global object is
E
.
<script src="https://unpkg.com/lauqe"></script>
<script>
console.log(E.equal(NaN, NaN)); // true
</script>
Contributions, issues and feature requests are welcome!
Feel free to check issues.
Give a βοΈ if this project helped you!
Copyright Β© 2021-present TomokiMiyauci.
Released under the MIT license