{"id":21073926,"url":"https://github.com/terraindata/terrain-keypath","last_synced_at":"2025-04-12T21:44:32.779Z","repository":{"id":97167043,"uuid":"163221387","full_name":"terraindata/terrain-keypath","owner":"terraindata","description":"An opinionated keypath type","archived":false,"fork":false,"pushed_at":"2021-05-11T01:30:36.000Z","size":21,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-12T21:43:52.103Z","etag":null,"topics":["deep","js","json","key-path","keypath"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/terraindata.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":"2018-12-26T22:08:52.000Z","updated_at":"2021-05-11T01:30:38.000Z","dependencies_parsed_at":null,"dependency_job_id":"e5146e53-28bc-4405-89d6-5c471bee92e4","html_url":"https://github.com/terraindata/terrain-keypath","commit_stats":{"total_commits":27,"total_committers":3,"mean_commits":9.0,"dds":"0.14814814814814814","last_synced_commit":"3b76ca460325e10f452d0a49350159a27abf1dee"},"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/terraindata%2Fterrain-keypath","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/terraindata%2Fterrain-keypath/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/terraindata%2Fterrain-keypath/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/terraindata%2Fterrain-keypath/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/terraindata","download_url":"https://codeload.github.com/terraindata/terrain-keypath/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248637833,"owners_count":21137538,"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","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":["deep","js","json","key-path","keypath"],"created_at":"2024-11-19T19:13:44.899Z","updated_at":"2025-04-12T21:44:32.757Z","avatar_url":"https://github.com/terraindata.png","language":"TypeScript","readme":"# terrain-keypath\n[![version](https://img.shields.io/npm/v/terrain-keypath.svg)](https://www.npmjs.org/package/terrain-keypath)\n[![dependencies](https://david-dm.org/terraindata/terrain-keypath.svg)](https://david-dm.org/terraindata/terrain-keypath)\n[![devDependencies](https://david-dm.org/terraindata/terrain-keypath/dev-status.svg)](https://david-dm.org/terraindata/terrain-keypath#info=devDependencies)\n\n_An opinionated keypath type_\n\nA natural task in JS is to query or modify an element of a deeply-nested JSON object.\nHowever, if you're doing operations like that frequently and involving dynamic, different\nelements, it becomes a pain to describe where all those elements are located within the\ndeep object.\n\n`terrain-keypath` provides a standard format for specifying elements of, among other\npossible use cases, deep JSON objects.  A `KeyPath` is an array of `WayPoint`s, each\nof which is a `string` or `number`.  For example, for the document\n```js\ndoc = {\n a: {\n  b: {\n   c: [\n     { d: 'e' },\n     { f: 'g' },\n   ]\n  }\n }\n}\n```\nyou would use e.g. `const kp = new KeyPath(['a', 'b', 'c', '1', 'f'])` to obtain\na reference to the object whose value is `'g'`.\n\n`KeyPath` makes the design decision that **every** `WayPoint` should be a `string`\n**unless** you are indicating the unique numeric **wildcard** token `-1`.  The\nsemantic intention of the wildcard token is to denote \"all children\" of an element,\ne.g. all entries of an array.  For example,\n`const kp = new KeyPath(['a', 'b', 'c', -1])`\nis meant to mean \"all children of a.b.c\".\n\nIt's worth emphasizing that **any** string is a valid JSON field name, including\nfield names with special characters like `.`, `*`, etc.  Thus, if you get a deep\nJSON document \"from the wild,\" there's no guarantee that other existing keypath\nlibraries (which typically use such special tokens as wildcards or waypoint\ndelimiters) will work.\n\nParticularly in conjunction with [yadeep](https://github.com/terraindata/yadeep),\nwe have tested `terrain-keypath` against a broad variety of wild JSON documents\nand have successfully deployed enterprise applications using this keypath type.\n\nTypeScript definitions included!\n\n## Installation\n\n    npm install terrain-keypath\n\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fterraindata%2Fterrain-keypath","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fterraindata%2Fterrain-keypath","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fterraindata%2Fterrain-keypath/lists"}