{"id":42415253,"url":"https://github.com/lyonbot/nd-weakmap","last_synced_at":"2026-01-28T01:58:50.107Z","repository":{"id":57309334,"uuid":"438977457","full_name":"lyonbot/nd-weakmap","owner":"lyonbot","description":"WeakMap with multiple dimensions, use a \"weak\" pair as WeakMap","archived":false,"fork":false,"pushed_at":"2021-12-17T07:32:32.000Z","size":77,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-09-22T16:53:03.925Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lyonbot.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-12-16T12:14:22.000Z","updated_at":"2021-12-20T05:08:18.000Z","dependencies_parsed_at":"2022-09-04T13:00:28.529Z","dependency_job_id":null,"html_url":"https://github.com/lyonbot/nd-weakmap","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/lyonbot/nd-weakmap","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lyonbot%2Fnd-weakmap","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lyonbot%2Fnd-weakmap/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lyonbot%2Fnd-weakmap/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lyonbot%2Fnd-weakmap/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lyonbot","download_url":"https://codeload.github.com/lyonbot/nd-weakmap/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lyonbot%2Fnd-weakmap/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28833227,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-27T23:29:49.665Z","status":"ssl_error","status_checked_at":"2026-01-27T23:25:58.379Z","response_time":168,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":[],"created_at":"2026-01-28T01:58:50.058Z","updated_at":"2026-01-28T01:58:50.102Z","avatar_url":"https://github.com/lyonbot.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# NDWeakMap\n\nWeakMap with multiple dimensions. Use array of objects as WeakMap's key.\n\n```\nnpm i nd-weakmap\nyarn add nd-weakmap\n```\n\n## Quick Start\n\n```js\nimport NDWeakMap from \"nd-weakmap\";\n\nconst map = new NDWeakMap();\n\n// ---------------------\n\nmap.set([aaa, bbb], \"this works\");\nmap.set([aaa, aaa], \"this works too\");\nmap.set([aaa], \"second stuff\");\n\nmap.get([aaa]) === \"second stuff\";\nmap.get([aaa, bbb]) === \"this works\";\nmap.get([aaa, aaa]) === \"this works too\";\n\n// ---------------------\n\nmap.delete([aaa]); // will NOT affect [aaa, bbb] \u0026 [aaa, aaa]\n\nmap.has([aaa]) === false;\nmap.has([aaa, aaa]) === true;\nmap.has([aaa, bbb]) === true;\n\n// ---------------------\n\nmap.deleteCascade([aaa]); // will delete [aaa, *] and [aaa, *, *] ...\n\nmap.has([aaa]) === false;\nmap.has([aaa, aaa]) === false; // deleted\nmap.has([aaa, bbb]) === false; // deleted\n\n// ---------------------\n\nmap.clear();\n```\n\n### Strict KeyTuple Length\n\nBy default, keyTuple's length may vary.\n\nYou can apply constraint to their length.\n\n```js\nimport NDWeakMap from \"nd-weakmap\";\n\n// optional constructor parameter\n// if is provided, `set()` and `delete()` will strictly check the keyTuple's length\n\nconst map = new NDWeakMap(2);\n//                        _\n//                        |\n//                        +--- Strict KeyTuple Length\n\nmap.set([aaa, bbb], \"this works\");\nmap.set([aaa], \"not work\"); // this throws Error\n\nmap.get([aaa]) === undefined; // this won't throw\n```\n\n### TypeScript\n\nYou may constraint the keyTuple's type. Meanwhile don't forget to set Strict KeyTuple Length!\n\n```ts\nimport NDWeakMap from \"nd-weakmap\";\n\ntype KeyTupleType = [any, any];\ntype ValueType = string;\n\nconst map = new NDWeakMap\u003cKeyTupleType, ValueType\u003e(2);\n//                                                 _\n//                                                 |\n//            (required) Strict KeyTuple Length ---+\n\nmap.set([aaa, bbb], \"this works\");\nmap.set([aaa], \"not work\"); // this throws Error\n\nmap.get([aaa]) === undefined; // this won't throw\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flyonbot%2Fnd-weakmap","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flyonbot%2Fnd-weakmap","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flyonbot%2Fnd-weakmap/lists"}