{"id":19042074,"url":"https://github.com/writetome51/is-match","last_synced_at":"2025-07-31T23:03:56.288Z","repository":{"id":57169569,"uuid":"351338704","full_name":"writetome51/is-match","owner":"writetome51","description":"A substitute for using === operator.  Useful when arrays don't have to be identical via === to be deemed a match.  They must only have identical content.","archived":false,"fork":false,"pushed_at":"2021-03-25T20:58:51.000Z","size":22,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-21T22:44:48.141Z","etag":null,"topics":["array","comparison","identical","javascript","match","matching"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/writetome51.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-03-25T06:59:30.000Z","updated_at":"2021-04-08T20:58:39.000Z","dependencies_parsed_at":"2022-09-11T02:10:19.072Z","dependency_job_id":null,"html_url":"https://github.com/writetome51/is-match","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/writetome51/is-match","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/writetome51%2Fis-match","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/writetome51%2Fis-match/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/writetome51%2Fis-match/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/writetome51%2Fis-match/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/writetome51","download_url":"https://codeload.github.com/writetome51/is-match/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/writetome51%2Fis-match/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268133631,"owners_count":24201374,"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","status":"online","status_checked_at":"2025-07-31T02:00:08.723Z","response_time":66,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["array","comparison","identical","javascript","match","matching"],"created_at":"2024-11-08T22:34:32.585Z","updated_at":"2025-07-31T23:03:56.259Z","avatar_url":"https://github.com/writetome51.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# isMatch(\u003cbr\u003e\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;item1: any,\u003cbr\u003e\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;item2: any\u003cbr\u003e): boolean\n \nWorks for any data type, but really intended for array comparison.  \nThe algorithm:\n```\nfunction isMatch(item1, item2) {\n    if (item1 === item2) return true;\n\n    if (isArray(item1) \u0026\u0026 isArray(item2) \u0026\u0026 (item1.length === item2.length)) {\n\n        for (let i = 0, length = item1.length; i \u003c length; ++i) {\n            if (not(isMatch( item1[i], item2[i] ))) return false;\n        }\n        return true;\n    }\n    else return false;\n}\n```\n\n## Examples\n```js\nisMatch([], []); // true\n\nisMatch(['a', 'b'],  ['a', 'b']); // true\n\nisMatch(['a', 'b'],  ['a', 'b', 'c']); // false\n\n// Elements must be in matching order to match:\nisMatch(['a', 'b', 'c'],  ['c', 'b', 'a']); // false\n\nisMatch([1, 2, [3]], [1, 2, [3]]); // true\n\nlet obj = {prop: 1};\nisMatch([obj], [{prop:1}]); // false\n\nlet obj2 = obj;\nisMatch([obj], [obj2]); // true\n\n\n// Behaves the same as === operator for primitive types and non-array objects:\n\nisMatch('', ''); // true\n\nisMatch('0', '0'); // true\n\nisMatch('0', 0); // false\n\nisMatch('00', '01'); // false\n\nisMatch(Infinity, Infinity); // true\n\nisMatch(undefined, undefined); // true\n\nlet obj = {prop: 1};\nisMatch(obj, {prop:1}); // false\n\nlet obj2 = obj;\nisMatch(obj, obj2); // true\n```\n\n## Installation\n`npm i  @writetome51/is-match`\n\n\n## Loading\n```js\nimport {isMatch} from '@writetome51/is-match'; \n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwritetome51%2Fis-match","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwritetome51%2Fis-match","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwritetome51%2Fis-match/lists"}