{"id":15629702,"url":"https://github.com/anko/array-keyed-map","last_synced_at":"2026-03-14T22:08:15.187Z","repository":{"id":34537315,"uuid":"180089255","full_name":"anko/array-keyed-map","owner":"anko","description":"JS datastructure, like Map, but the keys are arrays","archived":false,"fork":false,"pushed_at":"2023-05-16T20:59:47.000Z","size":307,"stargazers_count":40,"open_issues_count":4,"forks_count":3,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-09-20T06:55:08.567Z","etag":null,"topics":["array","data-structure","javascript","map","path"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/anko.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-04-08T07:01:21.000Z","updated_at":"2024-10-04T08:45:54.000Z","dependencies_parsed_at":"2024-06-18T15:32:19.734Z","dependency_job_id":"b23d1baf-83f0-4127-aa34-84336bd28614","html_url":"https://github.com/anko/array-keyed-map","commit_stats":{"total_commits":73,"total_committers":3,"mean_commits":"24.333333333333332","dds":0.452054794520548,"last_synced_commit":"690ba497a80782a91f80fa6de8ed8a3ad32aeaaa"},"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"purl":"pkg:github/anko/array-keyed-map","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anko%2Farray-keyed-map","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anko%2Farray-keyed-map/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anko%2Farray-keyed-map/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anko%2Farray-keyed-map/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/anko","download_url":"https://codeload.github.com/anko/array-keyed-map/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anko%2Farray-keyed-map/sbom","scorecard":{"id":197303,"data":{"date":"2025-08-11","repo":{"name":"github.com/anko/array-keyed-map","commit":"767ed3310a90f1509d14a369d9cea2e1b923d416"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.2,"checks":[{"name":"Code-Review","score":0,"reason":"Found 0/30 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/ci.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Pinned-Dependencies","score":3,"reason":"dependency not pinned by hash detected -- score normalized to 3","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:19: update your workflow using https://app.stepsecurity.io/secureworkflow/anko/array-keyed-map/ci.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/ci.yml:20: update your workflow using https://app.stepsecurity.io/secureworkflow/anko/array-keyed-map/ci.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/ci.yml:35: update your workflow using https://app.stepsecurity.io/secureworkflow/anko/array-keyed-map/ci.yml/master?enable=pin","Info:   0 out of   1 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   2 third-party GitHubAction dependencies pinned","Info:   1 out of   1 npmCommand dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: ISC License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Vulnerabilities","score":6,"reason":"4 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-v6h2-p8h4-qcjw","Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275","Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw","Warn: Project is vulnerable to: GHSA-j8xg-fqg3-53r7"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-16T22:03:56.165Z","repository_id":34537315,"created_at":"2025-08-16T22:03:56.166Z","updated_at":"2025-08-16T22:03:56.166Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30519201,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-14T19:51:21.629Z","status":"ssl_error","status_checked_at":"2026-03-14T19:51:12.959Z","response_time":57,"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":["array","data-structure","javascript","map","path"],"created_at":"2024-10-03T10:28:13.029Z","updated_at":"2026-03-14T22:08:15.158Z","avatar_url":"https://github.com/anko.png","language":"JavaScript","readme":"# array-keyed-map [![](https://img.shields.io/npm/v/array-keyed-map.svg?style=flat-square)](https://www.npmjs.com/package/array-keyed-map) [![](https://img.shields.io/github/checks-status/anko/array-keyed-map/master?style=flat-square)](https://github.com/anko/array-keyed-map/actions/workflows/ci.yml) [![](https://img.shields.io/coveralls/github/anko/array-keyed-map?style=flat-square)](https://coveralls.io/github/anko/array-keyed-map) ![](https://img.shields.io/endpoint?url=https://untitled-2flzixuijb4j.runkit.sh/array-keyed-map\u0026style=flat-square\u0026cacheSeconds=3600)\n\nA map data structure (a.k.a. associative array, dictionary) which maps from\narrays of arbitrary values (\"paths\") to arbitrary values.  Like if the JS\nbuilt-in [`Map`][map] took arrays as keys.  Uses the key objects' identities;\ndoes not stringify anything, [because that way lies madness](#faq).\n\n\u003c!-- !test program node test-readme-example.js --\u003e\n\n\u003c!-- !test check initial example --\u003e\n\n```js\nconst ArrayKeyedMap = require('array-keyed-map')\nconst m = new ArrayKeyedMap()\n\nconst obj = { x: true }\nconst objIdentical = { x: true }\nconst fun = function() {}\nconst reg = /regexp/\n\n// Set values\nm.set([obj],            1)\nm.set([obj, fun],       2)\nm.set([reg, reg, true], 3)\nm.set([],               4)\n\n// Get values\nconsole.log( m.get([obj]) )            // =\u003e 1\nconsole.log( m.get([objIdentical]) )   // =\u003e undefined\nconsole.log( m.get([obj, fun]) )       // =\u003e 2\nconsole.log( m.get([reg, reg, true]) ) // =\u003e 3\nconsole.log( m.get([]) )               // =\u003e 4\n```\n\nFeatures:\n\n- Implements all the same methods as [`Map`][map], with the only API difference\n  of *not iterating in insertion order*.\n- Stores paths compactly as a tree.  Shared prefixes are stored once only.\n- Algorithms are iterative, because it's faster than recursive.  (I checked.)\n- Thoroughly unit-tested.\n- No dependencies.\n\n## API\n\n### `new ArrayKeyedMap([iterable])`\n\n**Arguments:**\n\n - (optional) `iterable`: any iterable value of `[key, value]` entries from\n   which to initialise contents\n\n**Returns** ArrayKeyedMap `akmap`.\n\nArray keyed maps are iterable, so you can use them in `for`-loops, pass them to\n`Array.from`, pass them into the constructor to create a copy (`let copy = new\nArrayKeyedMap(akmap)`), etc.  (See [`.entries`](#akmapentries).)\n\n### `akmap.set(array, value)`\n\n**Arguments:**\n\n - `array`: `Array` of values\n - `value`: any value\n\nSets the value for the given array.\n\nObjects in the array are treated by identity.  The identity of the array object\nitself is irrelevant.\n\n**Returns** ArrayKeyedMap `akmap`: a reference to the same map, handy for\nchaining multiple `.set` calls.\n\n### `akmap.has(array)`\n\n**Arguments:**\n\n - `array`: `Array` of values\n\n**Returns** a Boolean: whether a previously set value exists for that key array.\n\n### `akmap.get(array)`\n\n**Arguments:**\n\n - `array`: `Array` of values\n\n**Returns** the previously assigned value for this array, or `undefined` otherwise.\n\n### `akmap.delete(array)`\n\n**Arguments:**\n\n - `array`: `Array` of values\n\nDeletes the value at this exact array.  Does not affect other array, even if\nthey are prefixes or extensions of this one.  Remember to do this if you no\nlonger need a array: the keys and values are not automatically\ngarbage-collected, even if the objects used as keys go out of scope!\n\n**Returns** a Boolean: `true` if an entry with that key existed and was\ndeleted, or `false` if no such entry was found.\n\n### `akmap.clear()`\n\nDeletes all entries from `akmap`.\n\n**Returns** `undefined`.\n\n### `akmap.hasPrefix(array)`\n\n**Arguments:**\n\n - `array`: `Array` of values\n\n**Returns** a Boolean: whether the map has some key starting with values\nmatching the given array.\n\n### `akmap.entries()`\n\n**Returns** an iterator that yields `[key, value]` for every entry in `akmap`.\n\n:warning: Note that these are in *arbitrary order; __not__ insertion order*!\nThis differs from the basic `Map`!\n\n### `akmap.keys()`\n\n**Returns** an iterator that yields the key part (type `Array`) of each entry\nin `akmap`.\n\n:warning: Note that these are in *arbitrary order; __not__ insertion order*!\nThis differs from the basic `Map`!\n\n### `akmap.values()`\n\n**Returns** an iterator that yields the value part of each entry in `akmap`.\n\n:warning: Note that these are in *arbitrary order; __not__ insertion order*!\nThis differs from the basic `Map`!\n\n### `akmap.forEach(callback[, thisArg])`\n\n**Arguments**:\n\n - `callback`:  `Function` that will be called for each entry in `akmap`,\n   passing the value, key, and map as arguments.\n - (optional) `thisArg`: `Object` passed to the `callback` as the value for\n   `this`.\n\n**Returns** `undefined`.\n\n:warning: Note that these are in *arbitrary order; __not__ insertion order*!\nThis differs from the basic `Map`!\n\n## Performance characteristics\n\n- The paths are stored as a tree.  If multiple paths are stored that share a\n  prefix, the prefix is not duplicated in storage, but shared between them.\n  For example: `['a', 'b']` and `['a', 'c']` have a shared prefix `['a']`.\n  Only 1 instance of `'a'` is stored, with `'b'` and `'c'` branching from it.\n\n  This means any operation involving a path scales linearly with that path's\n  length, as it is traversed.\n\n- `.size` is cached, so it does not traverse the data structure.\n\n- The algorithms are implemented iteratively, because the VM stack is faster\n  than a JS stack.\n\n## FAQ\n\n### Why is this better than stringify → `.join('/')` → regular `Map`?\n\n 1. Because you might want your key array to contain objects (by identity)\n    rather than strings, and objects cannot be stringified by identity, so\n    identical objects would get mixed up.  But this module can handle that:\n\n    \u003c!-- !test check by identity --\u003e\n\n    ```js\n    let akmap = new ArrayKeyedMap()\n    // These are distinct paths!\n    const path1 = [{}, {}, {}]\n    const path2 = [{}, {}, {}]\n    akmap.set(path1, 1)\n    akmap.set(path2, 2)\n    console.log(akmap.get(path1)) // → 1\n    console.log(akmap.get(path2)) // → 2\n    ```\n\n 2. Even if you only care about the object's content (and not identity),\n    objects may contain cyclic references, which can't be stringified in\n    isolation.  But this module can handle that.\n\n    \u003c!-- !test check cyclic --\u003e\n\n    ```js\n    const akmap = new ArrayKeyedMap()\n    const cyclic = {}\n    // Contains a reference to itself.  How would you stringify this?\n    cyclic.x = cyclic\n    akmap.set([ cyclic ], 1)\n    console.log(akmap.get([ cyclic ])) // → 1\n    ```\n\n 3. Even if you are only using string keys, the separator you choose (e.g. `/`)\n    may appear as part of your path elements, so the arrays `['a/b']` and\n    `['a', 'b']` would both resolve to the key `a/b` and overwrite each other.\n\n    So use a separator other than `/`?  Sure, but then you have the same\n    problem with elements possibly containing *that*.\n\n    So use a sufficiently long probabilistically unguessable separator like\n    `03f2a8291a700b95904190583dba17c4ae1bf3bdfc2834391d60985ac6724940`?  That\n    wastes RAM/disk.  Also this is the code police speaking, you are under\n    assert for crimes against humanity, go to BSD jail.\n\nSo please use this module instead of a hack.\n\n### What version of JS does this rely on?\n\nES2015 I think—it uses\n[`Map`](http://kangax.github.io/compat-table/es6/#test-Map)s and\n[`Symbol`](http://kangax.github.io/compat-table/es6/#test-Symbol)s (← caniuse\nlinks).  At time of writing, it works in any recent Node.js or browser.  Except\nIE, of course.\n\n## Development\n\nPull requests with improvements of any size are appreciated.  If anything about\nthe code or documentation is unclear, do ask.\n\nTo install the testing dependencies, run `npm install`.\n\nTo run the automated tests and coding style check, run `npm test`.\n\n## License\n\n[ISC](https://opensource.org/licenses/isc).\n\n[map]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanko%2Farray-keyed-map","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fanko%2Farray-keyed-map","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanko%2Farray-keyed-map/lists"}