{"id":15917603,"url":"https://github.com/dsfields/multikeymap-js","last_synced_at":"2025-10-13T17:09:09.648Z","repository":{"id":57305231,"uuid":"79963017","full_name":"dsfields/multikeymap-js","owner":"dsfields","description":"A multi-key hash table for JavaScript.","archived":false,"fork":false,"pushed_at":"2017-01-31T15:20:20.000Z","size":7,"stargazers_count":14,"open_issues_count":0,"forks_count":4,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-09-23T18:59:39.481Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/dsfields.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-01-24T22:58:28.000Z","updated_at":"2022-07-23T15:41:16.000Z","dependencies_parsed_at":"2022-09-20T01:12:54.804Z","dependency_job_id":null,"html_url":"https://github.com/dsfields/multikeymap-js","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/dsfields/multikeymap-js","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dsfields%2Fmultikeymap-js","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dsfields%2Fmultikeymap-js/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dsfields%2Fmultikeymap-js/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dsfields%2Fmultikeymap-js/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dsfields","download_url":"https://codeload.github.com/dsfields/multikeymap-js/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dsfields%2Fmultikeymap-js/sbom","scorecard":{"id":357647,"data":{"date":"2025-08-11","repo":{"name":"github.com/dsfields/multikeymap-js","commit":"e6ee86a3f7c329589f7e818ed96dde96c1321844"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":2.6,"checks":[{"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":-1,"reason":"No tokens found","details":null,"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":-1,"reason":"no dependencies found","details":null,"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":"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":"Dangerous-Workflow","score":-1,"reason":"no workflows found","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":"Code-Review","score":0,"reason":"Found 0/1 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":"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":"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":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"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":0,"reason":"license file not detected","details":["Warn: project does not have a license file"],"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"}}]},"last_synced_at":"2025-08-18T10:01:50.835Z","repository_id":57305231,"created_at":"2025-08-18T10:01:50.835Z","updated_at":"2025-08-18T10:01:50.835Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279016283,"owners_count":26085827,"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-10-13T02:00:06.723Z","response_time":61,"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":[],"created_at":"2024-10-06T18:11:49.288Z","updated_at":"2025-10-13T17:09:09.620Z","avatar_url":"https://github.com/dsfields.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# MultiKeyMap\n\nA `MultiKeyMap` functions much like a hash table, but it allows you to map more than one key to a single value.  In this scenario, an entry is keyed by an array of values.  The `MultiKeyMap` class does not place requirements on the order of values to set and get values.\n\n## Usage\n\nAdd the `multikeymap` module to your project:\n\n```sh\n$ npm install multikeymap -S\n```\n\nThen create instances of the `MultiKeyMap` class:\n\n```js\nconst MultiKeyMap = require('multikeymap');\n\nconst map = new MultiKeyMap();\n\nmap.set(['a', 'b', 'c'], '123');\n\nconsole.log( map.get(['a', 'b', 'c']) ); // 123\nconsole.log( map.get(['b', 'a', 'c']) ); // 123\nconsole.log( map.get(['c', 'a', 'b']) ); // 123\nconsole.log( map.get(['b', 'a']) ); // undefined\n```\n\n## API\n\n### Class: `MultiKeyMap`\n\nThe interface for the `MultiKeyMap` class looks very similar to the native ECMAScript `Map` object.\n\n`MultiKeyMap` instances store keys and values in a directed graph structure where each vertex is a key used in a keys array, and edges point to all associated key component.  This allows for lookups of values that do not depend on key array order.\n\n  * __Properties__\n\n    + `MultiKeyMap.prototype.size`: the number of entries in the `MultiKeyMap` instance.\n\n    + `MultiKeyMap.prototype[Symbol.toStringTag]`: the tag to use when stringifying the `MultiKeyMap` instance.\n\n    + `MultiKeyMap[Symbol.species]`: a reference to the `MultiKeyMap` constructor.\n\n  * __Methods__\n\n    + `MultiKeyMap.prototype.clear()`: clears the contents of the `MultiKeyMap` instance.\n\n    + `MultiKeyMap.prototype.delete(keys)`: deletes the entry associated with the given array of keys.  Returns a `Boolean` value indicating whether or not an item was actually deleted.  Parameters:\n\n      - `keys`: _(required)_ an array of keys referencing the entry to delete.\n\n    + `MultiKeyMap.prototype.entries()`: returns an ECMAScript [`Iterator`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Iterators_and_Generators) object that contains the key array and value pairs for each entry in the `MultiKeyMap` instance.\n\n    + `MultiKeyMap.prototype.forEach(callback [, thisArg])`: executes the provided function once for each keys array and value entry in the `MultiKeyMap` instance.  Parameters:\n\n      - `callback`: _(required)_ the function to call for each entry in the `MultiKeyMap` instance.  This function is called with the parameters:\n\n        - `keys`: the array of keys used to reference the entry.\n\n        - `value`: the value for the entry.\n\n        - `map`: a reference to the `MultiKeyMap` instance.\n\n      - `thisArg`: _(optional)_ value to use as `this` when executing `callback`.\n\n    + `MultiKeyMap.prototype.get(keys)`: returns the value for the given array of keys.  If no entry is found `undefined` is returned.  Parameters:\n\n      - `keys`: _(required)_ an array of keys referencing the entry to lookup.\n\n    + `MultiKeyMap.prototype.has(keys)`: returns a `Boolean` indicating whether or not the `MultiKeyMap` instance contains an entry for the given array of keys.\n\n      - `keys`: _(required)_ an array of keys referencing the entry to lookup.\n\n    + `MultiKeyMap.prototype.keys()`: returns an ECMAScript `Iterator` object that contains the key arrays for each entry in the `MultiKeyMap` instance.\n\n    + `MultiKeyMap.prototype.set(keys, value)`: sets a value for the given keys.  If there is already a value for the given `keys` it is overwritten with the new value.  Parameters:\n\n      - `keys`: _(required)_ an array of keys to reference the value.\n\n      - `value`: _(required)_ the value of the entry.\n\n    + `MultiKeyMap.prototype.traverse()`: returns a [`Traversor`](#class-traversor) object used to walk through the `MultiKeyMap` instance's internal graph to locate a specific value.\n\n    + `MultiKeyMap.prototype.values()`: returns an ECMAScript `Iterator` object that contains the values for each entry in the `MultiKeyMap` instance.\n\n    + `MultiKeyMap.prototype[Symbol.iterator]()`: returns the same ECMAScript `Iterator` object as `MultiKeyMap.prototype.entries()`.\n\n### Class: `Traversor`\n\nAn object used to traverse through a `MultiKeyMap` instance's internal graph structure one key component at a time.  This object functions similarly to an ECMAScript `Iterator`.  Advancing a `Traversor` is similar to a reducer function, in that all previously requested key values limit the next possible node the `Traversor` can visit.\n\nInstances of `Traversor` are created by calling `MultiKeyMap.prototype.traverse()`\n\n  * __Methods__\n\n    + `Traversor.prototype.next(key)`: advances the `Traversor` instance to the next specified key.  A call to `next()` amounts to hash lookup, and is performed in _O(1)_ constant time.  Parameters:\n\n      - `key`: the next key component to move to in the connected `MultiKeyMap`'s internal graph.\n\n      The `next()` method returns an object with the following keys:\n\n        - `done`: a `Boolean` value indicating whether or not there is a connected vertex with the given `key` name.  If this value is `true`, the `Traversor` has essentially hit a dead end, and cannot be advanced any further.\n\n        - `value`: the value at the current vertex.  If no value exists at the current vertext, then this is set to `undefined`.  This key is omitted if `done` is `true`.\n\n  * __Example__\n\n  ```js\n  const MultiKeyMap = require('multikeymap');\n\n  const map = new MultiKeyMap();\n\n  map.set(['a', 'b', 'c'], 'foo');\n  map.set(['a', 'c'], 'bar');\n  map.set(['a', 'b', 'c', 'd'], 'baz');\n\n  const traverse = map.traverse();\n\n  const b = traverse.next('b');\n  console.log(b); // { done: false, value: undefined }\n\n  const a = traverse.next('a');\n  console.log(a); // { done: false, value: undefined }\n\n  const c = traverse.next('c');\n  console.log(c); // { done: false, value: 'foo' }\n\n  const d = traverse.next('d');\n  console.log(d); // { done: false, value: 'baz' }\n\n  const e = traverse.next('e');\n  console.log(e); // { done: true }\n  ```\n\n## Performance\n\nThe `MultiKeyMap` class is read-optimized.  All lookups are done in _O(n)_ linear time, where _n_ is the number of items in a keys array.\n\n## Compatibility\n\nThis library is written using ECMAScript 2015 (version 6), and consequently may not be compatible with older browsers.  Specifically, this module utilizes `class`, `Map`, `Set`, and `Symbol`.  Refer to the [ECMAScript compatibility chart](https://kangax.github.io/compat-table/es6/) to see if the `multikeymap` module will work in your target browsers.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdsfields%2Fmultikeymap-js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdsfields%2Fmultikeymap-js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdsfields%2Fmultikeymap-js/lists"}