{"id":22021575,"url":"https://github.com/lamansky/kset","last_synced_at":"2026-05-15T21:32:43.960Z","repository":{"id":92611978,"uuid":"134623845","full_name":"lamansky/kset","owner":"lamansky","description":"[Node.js] Uses one or more keys to locate and set a value in a Map, Object, or other collection. Supports nesting, loose key matching, and more.","archived":false,"fork":false,"pushed_at":"2018-05-23T20:48:20.000Z","size":4,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-11-27T21:36:11.573Z","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,"governance":null}},"created_at":"2018-05-23T20:47:44.000Z","updated_at":"2018-05-23T20:48:22.000Z","dependencies_parsed_at":"2023-04-12T04:02:09.993Z","dependency_job_id":null,"html_url":"https://github.com/lamansky/kset","commit_stats":{"total_commits":1,"total_committers":1,"mean_commits":1.0,"dds":0.0,"last_synced_commit":"94ce44ef8eca134ada370a6d872ec0763f0cd9fe"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/lamansky/kset","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lamansky%2Fkset","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lamansky%2Fkset/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lamansky%2Fkset/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lamansky%2Fkset/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lamansky","download_url":"https://codeload.github.com/lamansky/kset/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lamansky%2Fkset/sbom","scorecard":{"id":577774,"data":{"date":"2025-08-11","repo":{"name":"github.com/lamansky/kset","commit":"94ce44ef8eca134ada370a6d872ec0763f0cd9fe"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3,"checks":[{"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":"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":"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":"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":"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":"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":"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":"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":"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":"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":"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:11.139Z","repository_id":92611978,"created_at":"2025-08-20T18:18:11.139Z","updated_at":"2025-08-20T18:18:11.139Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33080777,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-15T20:25:35.270Z","status":"ssl_error","status_checked_at":"2026-05-15T20:25:34.732Z","response_time":103,"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":"2024-11-30T06:13:00.579Z","updated_at":"2026-05-15T21:32:43.936Z","avatar_url":"https://github.com/lamansky.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# kset\n\nUses one or more keys to locate and set a value in 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 kset\n```\n\n## API\n\nThe module exports an `set()` function that has one other function attached to it as a method: `set.all()`.\n\n### `set()`\n\n#### Parameters\n\n1. Bindable: `collection` (Array, Map, Object, Set, Typed Array, or WeakMap): The key-value collection with the value to be set.\n2. `keychain` (any, or array of any): The key at which to set `value`, or an array of nested keys. If the key or key chain does not exist, it will be created.\n3. `value` (any): The new value.\n4. 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    * `construct` (function or false): A callback which constructs a new collection in the process of generating a nested key chain that does not already exist. The function is passed a zero-based numeric index indicating the level of nesting, and is expected to return a new collection object. To disable keychain construction altogether, set this to `false`.\n    * `elseReturn` (any): A value to return in the event that the set operation was unsuccessful. Only takes effect if no `elseThrow` is specified. Defaults to `undefined`.\n    * `elseThrow` (Error or string): An error to be thrown in the event that the set operation was unsuccessful. A string will be wrapped in an `Error` object automatically.\n    * `getType` (function): A callback which specifies the type of collection to be created in the process of generating a nested key chain that does not already exist. This callback is only used if `construct` is not set. The function is passed a zero-based numeric index indicating the level of nesting and is expected to return a class (`Object`, `Array`, `Map`, etc.) or the string name of a class (`'Object'`, `'Array'`, `'Map'`, etc.). If `getType` is not specified, the `types` argument will be used if present.\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    * `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 omitted, the default behavior will, among other things, consider arrays/objects to be equal if they have the same entries.\n    * `overwriteAncestors` (boolean): Whether or not to delete non-objects if necessary to resolve the `keychain`. If set to `false`, then the module will throw an error if `keychain` references a non-collection. Only applies if `elseThrow` is not set. Defaults to `false`.\n    * `overwrite` (boolean): Whether or not to allow an existing value to be replaced with `value`. Defaults to `true`.\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    * `set` (function): A callback which, if provided, will override the built-in code that sets the value of an individual key in 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 new value, the options object, and a callback for the built-in set behavior (to which your custom `set` callback can defer if it determines that it doesn’t need to override the default behavior after all).\n    * `type` or `types` (function, string, or array of functions/strings): A class, or its string name, that should be used to construct new collections if a nested key chain does not already exist. To specify different collection types for each level of nesting, put the types into an array. The `types` argument is used only if `construct` and `getType` are not specified. If neither argument is specified, newly-created nested collections will be of the same type as `collection`.\n\n#### Return Values\n\n* If no changes took place, returns `elseReturn` if set, otherwise `undefined`.\n* If setting the value was successful, returns the new value.\n\n#### Examples\n\n##### Arrays\n\n```javascript\nconst set = require('kset')\n\nconst arr = ['a', 'b', 'c']\nset(arr, 0, 'A') // 'A'\narr // ['A', 'b', 'c']\n```\n\n##### Maps\n\n```javascript\nconst set = require('kset')\n\nconst map = new Map([['key', 'old']])\nset(map, 'key', 'new') // 'new'\nmap.get('key') // 'new'\n\nconst nestedMap = new Map()\nset(nestedMap, ['key1', 'key2'], 'value') // 'value'\nnestedMap.get('key1').get('key2') // 'value'\n```\n\n##### Objects\n\n```javascript\nconst set = require('kset')\n\nconst obj = {key1: {}}\nset(obj, ['key1', 'key2'], 'value') // 'value'\nobj.key1.key2 // 'value'\n```\n\n### `set.all()`\n\nUse this method if you want to set multiple keys to the same value at once.\n\n#### Parameters\n\nThe parameters are the same as the main function, except that the second parameter is called `keychains` and accepts an array of `keychain` arguments.\n\n#### Return Value\n\nAn array of new values corresponding to the array of keychains. Each element will be the new value if it was set, otherwise `elseReturn` or `undefined`.\n\n#### Example\n\n```javascript\nconst set = require('kset')\n\nconst obj = {a: 1, b: 2, c: 3}\nset.all(obj, ['a', 'b'], 0) // [0, 0]\n\nobj.a // 0\nobj.b // 0\nobj.c // 3\n```\n\n## Related\n\nThe “k” family of modules works on keyed/indexed collections.\n\n* [khas](https://github.com/lamansky/khas)\n* [kget](https://github.com/lamansky/kget)\n* [kedit](https://github.com/lamansky/kedit)\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%2Fkset","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flamansky%2Fkset","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flamansky%2Fkset/lists"}