{"id":16720318,"url":"https://github.com/tomokimiyauci/equal","last_synced_at":"2025-03-21T21:30:38.451Z","repository":{"id":36968616,"uuid":"366744959","full_name":"TomokiMiyauci/equal","owner":"TomokiMiyauci","description":"TypeScript-first deep equivalence comparison between two values","archived":false,"fork":false,"pushed_at":"2023-01-07T07:29:33.000Z","size":1527,"stargazers_count":7,"open_issues_count":16,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-16T15:58:39.470Z","etag":null,"topics":["browser","deno","equal","equality","equivalent","is-equal","isequal","lodash","node","rambda","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/TomokiMiyauci.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":".github/CONTRIBUTING.md","funding":"FUNDING.yml","license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null},"funding":{"github":"TomokiMiyauci","patreon":"tomoki_miyauci"}},"created_at":"2021-05-12T14:30:47.000Z","updated_at":"2024-01-30T09:47:27.000Z","dependencies_parsed_at":"2023-01-17T09:45:45.647Z","dependency_job_id":null,"html_url":"https://github.com/TomokiMiyauci/equal","commit_stats":null,"previous_names":[],"tags_count":26,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TomokiMiyauci%2Fequal","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TomokiMiyauci%2Fequal/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TomokiMiyauci%2Fequal/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TomokiMiyauci%2Fequal/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/TomokiMiyauci","download_url":"https://codeload.github.com/TomokiMiyauci/equal/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244874094,"owners_count":20524572,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["browser","deno","equal","equality","equivalent","is-equal","isequal","lodash","node","rambda","typescript"],"created_at":"2024-10-12T22:06:36.546Z","updated_at":"2025-03-21T21:30:37.720Z","avatar_url":"https://github.com/TomokiMiyauci.png","language":"TypeScript","funding_links":["https://github.com/sponsors/TomokiMiyauci","https://patreon.com/tomoki_miyauci","https://www.patreon.com/tomoki_miyauci"],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n  \u003cimg alt=\"logo image\" src=\"https://res.cloudinary.com/dz3vsv9pg/image/upload/c_scale,w_1280/v1622422123/projects/equal/logo.png\" /\u003e\n  \u003ch1 align=\"center\"\u003eequal\u003c/h1\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\nTypeScript-first deep equivalence comparison between two values\n\u003c/p\u003e\n\n\u003cdiv align=\"center\"\u003e\n\n[![test](https://github.com/TomokiMiyauci/equal/actions/workflows/test.yml/badge.svg)](https://github.com/TomokiMiyauci/equal/actions/workflows/test.yml)\n[![GitHub release](https://img.shields.io/github/release/TomokiMiyauci/equal.svg)](https://github.com/TomokiMiyauci/equal/releases)\n[![deno land](http://img.shields.io/badge/available%20on-deno.land/x-lightgrey.svg?logo=deno\u0026labelColor=black)](https://deno.land/x/equal)\n[![nest badge](https://nest.land/badge.svg)](https://nest.land/package/equal)\n[![deno doc](https://doc.deno.land/badge.svg)](https://doc.deno.land/https/deno.land/x/equal/mod.ts)\n[![deno version](https://img.shields.io/badge/deno-^1.6.0-lightgrey?logo=deno)](https://github.com/denoland/deno)\n![node support version](https://img.shields.io/badge/node-%5E6.17.0-yellow)\n![npm download](https://img.shields.io/npm/dw/lauqe?color=blue)\n\n![GitHub (Pre-)Release Date](https://img.shields.io/github/release-date-pre/TomokiMiyauci/equal)\n[![dependencies Status](https://status.david-dm.org/gh/TomokiMiyauci/equal.svg)](https://david-dm.org/TomokiMiyauci/equal)\n[![codecov](https://codecov.io/gh/TomokiMiyauci/equal/branch/main/graph/badge.svg?token=SPAi5Pv2wd)](https://codecov.io/gh/TomokiMiyauci/equal)\n[![Codacy Badge](https://app.codacy.com/project/badge/Grade/f43b1c317e11445399d85ce6efc06504)](https://www.codacy.com/gh/TomokiMiyauci/equal/dashboard?utm_source=github.com\u0026utm_medium=referral\u0026utm_content=TomokiMiyauci/equal\u0026utm_campaign=Badge_Grade)\n![npm type definitions](https://img.shields.io/npm/types/lauqe)\n![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)\n![Gitmoji](https://img.shields.io/badge/gitmoji-%20😜%20😍-FFDD67.svg?style=flat)\n![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](./LICENSE)\n\n\u003c/div\u003e\n\n---\n\nEquivalent comparison of Object data structures. It supports many built-in\nobjects and can be compared with `Date`, `Array` or `Object`.\n\nThe supported built-in objects are [here](#built-in-objects).\n\nIt provides `equal` functions and specific data types functions . The `equal`\nfunction works correctly in all situations. The specific data types functions\nworks correctly only for specific data types, but it has good performance.\nPlease check [bundle size optimization](####bundle-size-optimization) for\ndetails.\n\n## :bookmark: Table of Contents\n\n- [Features](#sparkles-features)\n- [Example](#zap-example)\n- [Usage](#dizzy-usage)\n- [API](#memo-api)\n- [Supports](#green_heart-supports)\n- [Contributing](#handshake-contributing)\n- [Show your support](#seedling-show-your-support)\n- [License](#bulb-license)\n\n## :sparkles: Features\n\n- :zap: Multi runtime support (`Deno`, `Node.js` and Browsers)\n- :books: Pure TypeScript and provides type definition\n- :white_check_mark:\n  [Rambda](https://selfrefactor.github.io/rambda/#/?id=equals)'s all test case\n  is passed\n- :earth_americas: Universal module, providing `ES modules` and `Commonjs`\n- :package: Optimized, super slim size\n- :page_facing_up: TSDoc-style comments\n\n### Package name\n\nDeno: `equal` ([deno.land](https://deno.land/x/equal),\n[nest.land](https://nest.land/package/equal))\n\nNode.js: `lauqe` ([npm](https://www.npmjs.com/package/lauqe))\n\n## :zap: Example\n\n### [Primitive](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#primitive_values)\n\n```ts\nequal(\"\", \"\"); // true\nequal(NaN, NaN); // true\nequal(0, 0); // true\nequal(+0, 0); // true\nequal(-0, 0); // true\nequal(+0, -0); // true\nequal(0n, 0n); // true\nequal(undefined, undefined); // true\nequal(null, null); // true\nequal(undefined, null); // false\nequal(true, false); // false\nconst symbol = Symbol(\"hello\");\nequal(symbol, symbol); // true\nequal(Symbol(\"hello\"), Symbol(\"hello\")); // false\n```\n\n### [Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#objects)\n\n```ts\nequal({}, {}) // true\nequal({ \"\": undefined }, { \"\": undefined }) // true\nequal({ \"\": undefined }, { \"\": undefined, a: 1 }) // false\nequal({ a: 1, b: undefined}, { b: undefined, a: 1}) // true\nequal([], []) // true\nequal([[[]]], [[[]]]) // true\nequal(new Date(\"2000/1/1\"), new Date(\"2000/1/1\")) // true\nequal(() =\u003e true, () =\u003e true) // true\nequal(AggregateError([ Error(\"error\"), TypeError(\"type error\") ]), AggregateError([ Error(\"error\"), TypeError(\"type error\") ])) // true\nequal(/s/, /s/) // true\nequal(new String('hello'), new String('hello')) // true\nequal(new Number(0), new Number(0)) // true\nequal(new Boolean(true), new Boolean(true)) // true\nequal(new Map([[1, 2], [3, 4]]), new Map([[3, 4], [1, 2]]) // true\n```\n\n## :dizzy: Usage\n\n`equal` provides multi platform modules.\n\n### 🦕 Deno\n\n#### [deno.land](https://deno.land/x/equal)\n\n```ts\nimport { equal } from \"https://deno.land/x/equal/mod.ts\";\n\nequal([1, 2, 3], [1, 2, 3]); // true\n```\n\n#### [nest.land](https://nest.land/package/equal)\n\n```ts\nimport { equal } from \"https://x.nest.land/equal/mod.ts\";\n\nequal([1, ['hello', ['world']], [1, ['hello', ['world']]); // true\n```\n\n### :package: Node.js\n\n\u003e NPM package name is [`lauqe`](https://www.npmjs.com/package/lauqe) .\n\n#### Install\n\n```bash\nnpm i lauqe\nor\nyarn add lauqe\n```\n\n#### ES modules\n\n```ts\nimport { equal } from \"lauqe\";\n\nequal(new Date(\"2000/1/1\"), new Date(\"2000/1/1\")); // true\n```\n\n#### Commonjs\n\n```ts\nconst { equal } = require(\"lauqe\");\n\nequal(/hello/g, /hello/g); // true\n```\n\n### :globe_with_meridians: Browser\n\nThe module that bundles the dependencies is obtained from\n[skypack](https://www.skypack.dev/view/lauqe).\n\n```html\n\u003cscript type=\"module\"\u003e\n  import { equal } from \"https://cdn.skypack.dev/lauqe\";\n  console.log(equal(() =\u003e {}, () =\u003e {}); // true\n\u003c/script\u003e\n```\n\n## :memo: API\n\n### Definition of Equality\n\nEquality is defined as the data structure and property values are equivalent.\n\n#### Same-value-zero\n\nNumerical equivalence is based on\n[Same-value-zero](https://developer.mozilla.org/docs/Web/JavaScript/Equality_comparisons_and_sameness#same-value-zero_equality).\\\nThat is, all of the following comparisons are considered equivalent.\n\n```ts\nequal(NaN, NaN); // true\nequal(0, 0); // true\nequal(+0, 0); // true\nequal(-0, 0); // true\nequal(+0, -0); // true\n```\n\n### Built-in objects\n\nThe following objects work correctly.\n\n- [`Array`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)\n- [`Typed Array`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Typed_arrays)\n  (\n  [`Int8Array`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Int8Array),\n  [`Uint8Array`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array),\n  [`Uint8ClampedArray`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8ClampedArray),\n  [`Int16Array`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Int16Array),\n  [`Uint16Array`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint16Array),\n  [`Int32Array`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Int32Array),\n  [`Uint32Array`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint32Array),\n  [`Float32Array`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Float32Array),\n  [`Float64Array`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Float64Array),\n  [`BigInt64Array`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt64Array),\n  [`BigUint64Array`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigUint64Array)\n  )\n- [`ArrayBuffer`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer)\n- [`Object`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)\n- [`Date`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date)\n- [`Error`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error)\n  (\n  [`EvalError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/EvalError),\n  [`RangeError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RangeError),\n  [`ReferenceError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ReferenceError),\n  [`SyntaxError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SyntaxError),\n  [`TypeError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypeError),\n  [`URIError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/URIError),\n  [`AggregateError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/AggregateError)\n  )\n- [`RegExp`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp)\n- [`Map`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Keyed_collections#maps)\n- [`Set`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Keyed_collections#sets)\n- [`URL`](https://developer.mozilla.org/en-US/docs/Web/API/URL)\n- [`URLSearchParams`](https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams)\n- [`String`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)\n- [`Number`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)\n- [`Boolean`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)\n\n**Do not guarantee** the behavior of objects not on this list.\n\n### Bundle size optimization\n\nThe `equal` function works correctly for all supported\n[built-in objects](#built-in-objects). The price is an increase in bundle size.\n\nIf the data to be compared for equivalence is of multiple data types, or if the\ndata types are unclear, the `equal` function may be the best choice.\n\nIf the data type is predetermined, you can reduce the bundle size by using the\nspecific function instead.\n\n### Type definition\n\n#### equal\n\nCompare the equivalence of the all supported\n[built-in objects](#built-in-objects) and primitive values .\n\n```ts\ndeclare const equal: \u003cT, U extends T\u003e(a: T, b: U) =\u003e boolean;\n```\n\n| Parameter | Description |\n| --------- | ----------- |\n| `a`       | Any value   |\n| `b`       | Any value   |\n\n`=\u003e` Return `true` if the reference memory is the same or the property members\nand their values are the same\n\n#### equalDate\n\nCompare the equivalence of `Date` objects.\n\n```ts\ndeclare const equalDate: (a: Date, b: Date) =\u003e boolean;\n```\n\n##### Example\n\n```ts\nequalDate(new Date(0), new Date(0)) // true\nequalDate(new Date(0), new Date(1)) // false\nequalDate(new Date(\"1999/1/1 00:00:01\"), new Date(\"1999/1/1\")) // false\n// invalid date\n[new Date(\"a\"), new Date(\"a\"), true],\n[new Date(\"a\"), new Date(\"b\"), true],\n```\n\n#### equalPrimitive\n\nCompare the equivalence of Primitive values.\n\n```ts\ndeclare const equalPrimitive: \u003cT extends Primitive, U extends T\u003e(\n  a: T,\n  b: U,\n) =\u003e boolean;\n\ntype Primitive =\n  | string\n  | number\n  | bigint\n  | boolean\n  | symbol\n  | undefined\n  | null;\n```\n\n##### Example\n\n```ts\nequalPrimitive(NaN, NaN); // true\nequalPrimitive(0, +0); // true\nequalPrimitive(-0, +0); // true\n```\n\n#### equalError\n\nCompare the equivalence of the `Error` object and its Derived object.\n\n```ts\ndeclare const equalError: (a: Error, b: Error) =\u003e boolean;\n```\n\n##### Example\n\n```ts\nequalError(Error(\"test\"), Error(\"test\")); // true\nequalError(\n  AggregateError([TypeError(\"test\")]),\n  AggregateError([TypeError(\"test\")]),\n); // true\nequalError(Error(\"test\"), Error(\"hello\")); // false\nequalError(Error(\"test\"), TypeError(\"test\")); // false\n```\n\n#### equalURL\n\nCompare the equivalence of `URL` objects.\n\n```ts\ndeclare const equalURL: (a: URL, b: URL) =\u003e boolean;\n```\n\n##### Example\n\n```ts\nequalURL(new URL(\"https://google.com\", \"https://google.com\")); // true\nequalURL(new URL(\"https://google.com\", \"https://google.com/\")); // true\n```\n\n#### equalArrayBuffer\n\nCompare the equivalence of `ArrayBuffer` objects.\n\n```ts\ndeclare const equalArrayBuffer: (a: ArrayBuffer, b: ArrayBuffer) =\u003e boolean;\n```\n\nExample\n\n```ts\nequalArrayBuffer(new ArrayBuffer(0), new ArrayBuffer(0)); // true\nequalArrayBuffer(new ArrayBuffer(0), new ArrayBuffer(1)); // false\n```\n\n## :green_heart: Supports\n\n\u003e ie is no longer supported to reduce bundle size.\n\nThe TypeScript version must be `4.1.0` or higher.\n\nThis project provides `ES modules` and `Commonjs`.\n\nIf you have an opinion about what to support, you can open an\n[issue](https://github.com/TomokiMiyauci/equal/issues) to discuss it.\n\nThe `browserslist` has the following settings.\n\n```text\ndefaults\nlast 8 version\nnot IE \u003c= 11\nnot ie_mob \u003c= 11\nnode 6\n```\n\n| \u003cimg width=\"30px\" height=\"30px\" alt=\"Deno\" src=\"https://res.cloudinary.com/dz3vsv9pg/image/upload/v1620998361/logos/deno.svg\"\u003e\u003c/br\u003eDeno | \u003cimg width=\"24px\" height=\"24px\" alt=\"Node.js\" src=\"https://res.cloudinary.com/dz3vsv9pg/image/upload/v1620998361/logos/nodejs.svg\"\u003e\u003c/br\u003eNode.js | \u003cimg width=\"24px\" height=\"24px\" alt=\"IE / Edge\" src=\"https://raw.githubusercontent.com/alrra/browser-logos/master/src/edge/edge_48x48.png\"\u003e\u003c/br\u003eEdge | \u003cimg src=\"https://raw.githubusercontent.com/alrra/browser-logos/master/src/firefox/firefox_48x48.png\" alt=\"Firefox\" width=\"24px\" height=\"24px\" /\u003e\u003c/br\u003eFirefox | \u003cimg src=\"https://raw.githubusercontent.com/alrra/browser-logos/master/src/chrome/chrome_48x48.png\" alt=\"Chrome\" width=\"24px\" height=\"24px\" /\u003e\u003c/br\u003eChrome | \u003cimg src=\"https://raw.githubusercontent.com/alrra/browser-logos/master/src/safari/safari_48x48.png\" alt=\"Safari\" width=\"24px\" height=\"24px\" /\u003e\u003c/br\u003eSafari | \u003cimg src=\"https://raw.githubusercontent.com/alrra/browser-logos/master/src/safari-ios/safari-ios_48x48.png\" alt=\"iOS Safari\" width=\"24px\" height=\"24px\" /\u003e\u003c/br\u003eiOS Safari | \u003cimg src=\"https://raw.githubusercontent.com/alrra/browser-logos/master/src/samsung-internet/samsung-internet_48x48.png\" alt=\"Samsung\" width=\"24px\" height=\"24px\" /\u003e\u003c/br\u003eSamsung | \u003cimg src=\"https://raw.githubusercontent.com/alrra/browser-logos/master/src/opera/opera_48x48.png\" alt=\"Opera\" width=\"24px\" height=\"24px\" /\u003e\u003c/br\u003eOpera |\n| --------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------- |\n| `^1.6.0`                                                                                                                                | `^6.17.0`                                                                                                                                       | `^83`                                                                                                                                                | `^78`                                                                                                                                                         | `^83`                                                                                                                                                     | `^11`                                                                                                                                                     | `^12.0`                                                                                                                                                                   | `^7.2`                                                                                                                                                                          | `^68`                                                                                                                                                 |\n\n## :handshake: Contributing\n\nContributions, issues and feature requests are welcome!\u003cbr /\u003eFeel free to check\n[issues](https://github.com/TomokiMiyauci/equal/issues).\n\n[Contributing guide](./.github/CONTRIBUTING.md)\n\n## :seedling: Show your support\n\nGive a ⭐️ if this project helped you!\n\n\u003ca href=\"https://www.patreon.com/tomoki_miyauci\"\u003e\n  \u003cimg src=\"https://c5.patreon.com/external/logo/become_a_patron_button@2x.png\" width=\"160\"\u003e\n\u003c/a\u003e\n\n## :bulb: License\n\nCopyright © 2021-present [TomokiMiyauci](https://github.com/TomokiMiyauci).\n\nReleased under the [MIT](./LICENSE) license\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftomokimiyauci%2Fequal","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftomokimiyauci%2Fequal","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftomokimiyauci%2Fequal/lists"}