{"id":22021525,"url":"https://github.com/lamansky/kget","last_synced_at":"2026-04-18T13:32:52.712Z","repository":{"id":46224263,"uuid":"134590870","full_name":"lamansky/kget","owner":"lamansky","description":"[Node.js] Uses one or more keys to retrieve a value from a Map, Object, or other collection. Supports nesting, loose key matching, and more.","archived":false,"fork":false,"pushed_at":"2021-11-04T09:40:03.000Z","size":8,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-03T13:36:50.433Z","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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lamansky.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"license.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-05-23T15:36:05.000Z","updated_at":"2019-11-23T21:42:54.000Z","dependencies_parsed_at":"2022-09-10T21:51:12.644Z","dependency_job_id":null,"html_url":"https://github.com/lamansky/kget","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/lamansky/kget","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lamansky%2Fkget","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lamansky%2Fkget/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lamansky%2Fkget/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lamansky%2Fkget/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lamansky","download_url":"https://codeload.github.com/lamansky/kget/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lamansky%2Fkget/sbom","scorecard":{"id":577771,"data":{"date":"2025-08-11","repo":{"name":"github.com/lamansky/kget","commit":"db8d531e913c8eb132cb5eb036c55245394766d9"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3,"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":"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":"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":"Code-Review","score":0,"reason":"Found 0/6 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":-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":"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":"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":"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":"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":"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":"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":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: license.txt:0","Info: FSF or OSI recognized license: MIT License: license.txt: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"}}]},"last_synced_at":"2025-08-20T18:18:08.947Z","repository_id":46224263,"created_at":"2025-08-20T18:18:08.947Z","updated_at":"2025-08-20T18:18:08.947Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31971487,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-18T00:39:45.007Z","status":"online","status_checked_at":"2026-04-18T02:00:07.018Z","response_time":103,"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-11-30T06:12:37.994Z","updated_at":"2026-04-18T13:32:52.696Z","avatar_url":"https://github.com/lamansky.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# kget\n\nUses one or more keys to retrieve a value from a Map, Object, or other collection. Supports nesting, loose key matching, and more.\n\n## Installation\n\nRequires [Node.js](https://nodejs.org/) 8.3.0 or above.\n\n```bash\nnpm i kget\n```\n\n## API\n\nThe module exports a function (`get()`) that has other functions attached to it as methods (e.g. `get.any()`).\n\n### `get()`\n\n#### Parameters\n\n1. Bindable: `collection` (Array, iterator, Map, Object, Set, string, Typed Array, or WeakMap): The key-value collection from which to retrieve a value.\n2. `keychain` (any, or array of any): A key to retrieve, or an array of nested keys.\n3. Optional: Object argument:\n    * `arrays` / `maps` / `sets` / `weakMaps` (arrays of classes/strings): Arrays of classes and/or string names of classes that should be treated as equivalent to `Array`/`Map`/`Set`/`WeakMap` (respectively).\n    * `elseReturn` (any): A value to return if `keychain` is an invalid reference. Only takes effect if no `elseThrow` is specified. Defaults to `undefined`.\n    * `elseThrow` (Error or string): An error to be thrown if `keychain` is an invalid reference. A string will be wrapped in an `Error` object automatically.\n    * `get` (function): A callback which, if provided, will override the built-in code that fetches an individual key from a collection. Use this if you need to support collections whose custom APIs preclude the use of parameters like `maps`. The callback will be called with five arguments: the collection, the key, the options object, the fallback to return if the key is not found, and a callback for the built-in get behavior (to which your custom `get` callback can defer if it determines that it doesn’t need to override the default behavior after all).\n    * `inObj` (boolean): Whether or not to search inherited properties if `collection` is an Object (i.e. not another recognized type). Defaults to `false`.\n    * `loose` (boolean): Whether or not to evaluate keys loosely (as defined by `looselyEquals`). Defaults to `false`.\n    * `looselyEquals` (function): A callback that accepts two values and returns `true` if they are to be considered equivalent or `false` otherwise. This argument is only used if `loose` is `true`. If this option is omitted, then the [`equals`](https://www.npmjs.com/package/equals) module is used. This module will, among other things, consider arrays/objects to be equal if they have the same entries.\n    * `numerifyIndexes` (boolean): Set to `true` to convert number-containing key strings to numbers. This is most useful when the `split` option is enabled: if you use `split` to divide a `'key.0'` keychain into `'key'` and `'0'`, enabling this option will result in the `'0'` key being converted to a numeric `0` index. Defaults to `false`.\n    * `preferStrict` (boolean): Only applies if `loose` is `true`. If `true`, then strictly-identical keys will be preferred over loosely-equivalent keys. Otherwise, the first loosely-equivalent key found will be used, even if a strictly-identical one comes later. Defaults to `false`.\n    * `reverse` (boolean): Set to `true` to use the _last_ matching key instead of the first one. Only applies if `loose` is `true`. Defaults to `false`.\n    * `split` (boolean or object): Set to `true` to parse dot-separated `keychain` strings (e.g. `'key1.key2'`) as separate keys. You can also provide an object of options to be forwarded to the [`split-string`](https://www.npmjs.com/package/split-string) module. Defaults to `false`.\n\n#### Return Values\n\n* Returns the value from `collection` referenced by `keychain`.\n* If no such value is found, returns `elseReturn` if set.\n* Otherwise returns `undefined`.\n\n#### Example\n\nIn the following example, `kget` fetches a map key, then an object key, then a string index:\n\n```javascript\nconst get = require('kget')\n\nconst map = new Map()\nmap.set('mapKey', {objKey: 'string'})\n\nget(map, ['mapKey', 'objKey', 5]) // 'g'\n```\n\n### `get.any()`\n\nHas the same signature as the main function, except that the second parameter is called `keychains` and expects an array of keys or keychain arrays to be tried one-by-one until one of them points to a value.\n\n#### Example\n\n```javascript\nconst get = require('kget')\n\nget.any({c: 3, d: 4}, [['a', 'subkey'], 'b', 'c']) // 3\n```\n\nThe function tries the keys `a.subkey`, `b`, and `c` in order. The first key found (`c`) has its value returned.\n\n### `get.in()`\n\nThis method is an alias for calling the main `get()` method with the `inObj` option set to `true`.\n\n### `get.any.in()`\n\nThis method is an alias for calling `get.any()` with the `inObj` option set to `true`.\n\n### `get.key()`\n\nThis method allows you to determine the key that would be retrieved when loose equivalence is used.\n\n#### Parameters\n\n1. Bindable: `collection` (Array, iterator, Map, Object, Set, string, or Typed Array): The key-value collection from which to retrieve a value.\n2. `key` (any): A key which may or may not exist in `collection`. (This can only be a single key, not a key chain.)\n3. Optional: Object argument: The same options as in the base `get()` function.\n\n#### Return Values\n\n* If `key` exists in `collection`:\n    * If `loose` is set to `true` in the options argument, the first key in `collection` that is loosely equal to `key` will be returned.\n    * Otherwise, `key` is returned as-is.\n* If `key` does _not_ exist in `collection`, the return value is `undefined`.\n\n#### Example\n\n```javascript\nconst get = require('kget')\n\nconst a = ['key']\nconst b = ['key']\n\nconst map = new Map()\nmap.set(a, 'value a')\nmap.set(b, 'value b')\n\nget(map, b) // 'value b'\nget(map, b, {loose: true}) // 'value a'\n\nget.key(map, b) === b // true\nget.key(map, b, {loose: true}) === a // true\n```\n\n### `get.entry()`\n\n#### Parameters\n\n1. Bindable: `collection` (Array, iterator, Map, Object, Set, string, or Typed Array): The key-value collection from which to retrieve a value.\n2. `key` (any): A key which may or may not exist in `collection`. (This can only be a single key, not a key chain.)\n3. Optional: Object argument: Any of (as defined above): `arrays`, `maps`, `sets`, `weakMaps`, `elseReturn`, `elseThrow`, `inObj`, `loose`, `looselyEquals`, and `preferStrict`.\n\n#### Return Values\n\n* If the `key` is found, returns a two-element array containing the matched key and the retrieved value.\n* If the `key` is not found, returns `elseReturn` if provided, otherwise `undefined`.\n\n## Related\n\nThe “k” family of modules works on keyed/indexed collections.\n\n* [khas](https://github.com/lamansky/khas)\n* [kedit](https://github.com/lamansky/kedit)\n* [kset](https://github.com/lamansky/kset)\n* [kinc](https://github.com/lamansky/kinc)\n* [kdel](https://github.com/lamansky/kdel)\n\nThe “v” family of modules works on any collection of values.\n\n* [vhas](https://github.com/lamansky/vhas)\n* [vget](https://github.com/lamansky/vget)\n* [vsize](https://github.com/lamansky/vsize)\n* [vadd](https://github.com/lamansky/vadd)\n* [vdel](https://github.com/lamansky/vdel)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flamansky%2Fkget","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flamansky%2Fkget","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flamansky%2Fkget/lists"}