{"id":15616641,"url":"https://github.com/saibotsivad/pointer-props","last_synced_at":"2025-10-13T04:33:00.485Z","repository":{"id":57326717,"uuid":"411034371","full_name":"saibotsivad/pointer-props","owner":"saibotsivad","description":"JavaScript object manipulation (get/set/del) using JSON Pointer (RFC6901) and JSON Reference syntax.","archived":false,"fork":false,"pushed_at":"2022-03-02T20:06:44.000Z","size":41,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-11T05:34:53.577Z","etag":null,"topics":["javascript","json-pointer","json-reference","jsonpointer","jsonreference","rfc6901"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/saibotsivad.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-09-27T20:32:09.000Z","updated_at":"2022-02-23T18:22:43.000Z","dependencies_parsed_at":"2022-09-21T02:01:29.529Z","dependency_job_id":null,"html_url":"https://github.com/saibotsivad/pointer-props","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"purl":"pkg:github/saibotsivad/pointer-props","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saibotsivad%2Fpointer-props","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saibotsivad%2Fpointer-props/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saibotsivad%2Fpointer-props/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saibotsivad%2Fpointer-props/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/saibotsivad","download_url":"https://codeload.github.com/saibotsivad/pointer-props/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saibotsivad%2Fpointer-props/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279012502,"owners_count":26085133,"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-12T02:00:06.719Z","response_time":53,"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":["javascript","json-pointer","json-reference","jsonpointer","jsonreference","rfc6901"],"created_at":"2024-10-03T07:20:22.953Z","updated_at":"2025-10-13T04:33:00.455Z","avatar_url":"https://github.com/saibotsivad.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# pointer-props\n\nJavaScript object manipulation (get/set/del) using JSON Pointer (RFC6901) syntax, and optional resolution of [JSON References](https://datatracker.ietf.org/doc/html/draft-pbryan-zyp-json-ref-03).\n\n## Install\n\nThe usual ways:\n\n```shell\nnpm install pointer-props\n```\n\n## Example\n\nGet or set a property, either using the JSON Pointer string or with an array:\n\n```js\nimport { get, set } from 'pointer-props'\nconst obj = { foo: { bar: 3 } }\nget(obj, '/foo/bar') // =\u003e 3\nget(obj, [ 'foo', 'bar' ]) // =\u003e 3\nset(obj, '/foo/bar', 4) // =\u003e { foo: { bar: 4 } }\nset(obj, [ 'foo', 'bar' ], 5) // =\u003e { foo: { bar: 5 } }\n```\n\nResolve JSON Reference paths to the final non-referenced path (as an array):\n\n```js\nimport { resolve } from 'pointer-props'\nconst obj = {\n\tfoo: { $ref: '#/fizz/buzz' },\n\tfizz: { buzz: 3 }\n}\nresolve('#/foo/bar') // =\u003e [ 'fizz', 'buzz' ]\n```\n\nHandles escaped strings, as expected:\n\n```js\nconst obj = {\n\t'f/o/o': {\n\t\t'b~a~r': 3\n\t}\n}\nget(obj, '/f~1o~1o/b~0a~0r') // =\u003e 3\n```\n\nGenerate escaped strings from a list of tokens, or a list of tokens from a string:\n\n```js\nimport { toPointer, toTokens } from 'pointer-props'\ntoPointer([ 'a/b', 'c~d' ]) // =\u003e \"/a~1b/c~0d\"\ntoTokens('/a~1b/c~0d') // =\u003e [ \"a/b\", \"c~d\" ]\n```\n\n## API\n\nUnder the hood, the get/set functions use the amazing [`dset`](https://github.com/lukeed/dset) and [`dlv`](https://github.com/developit/dlv),\nwhich should be pretty familiar.\n\n### `function get(obj: any, path: string | ArrayLike\u003cstring | number\u003e): any`\n\nGet a property using either a JSON Pointer string, or an array of already-unescaped accessor tokens.\n\n```js\nimport { get } from 'pointer-props'\nconst obj = { foo: { bar: 3 } }\nget(obj, '/foo/bar') // =\u003e 3\nget(obj, [ 'foo', 'bar' ]) // =\u003e 3\n```\n\n### `function set\u003cT extends object, V\u003e(obj: T, path: string | ArrayLike\u003cstring | number\u003e, value: V): T`\n\nSet a property using either a JSON Pointer string, or an array of already-unescaped accessor tokens.\n\nFor convenience, the modified object is also returned.\n\n```js\nimport { set } from 'pointer-props'\nconst obj = {}\nset(obj, '/foo/bar', 3)\nconsole.log(obj.foo.bar) // =\u003e 3\nset(obj, [ 'foo', 'bar' ], 4)\nconsole.log(obj.foo.bar) // =\u003e 4\n```\n\n### `function del\u003cT extends object\u003e(obj: T, path: string | ArrayLike\u003cstring | number\u003e): T`\n\nRemove a property using either a JSON Pointer string, or an array of already-unescaped accessor tokens.\n\nFor convenience, the modified object is also returned.\n\n```js\nimport { set } from 'pointer-props'\nconst obj = {}\nset(obj, '/foo/bar', 3)\nconsole.log(obj.foo.bar) // =\u003e 3\nset(obj, [ 'foo', 'bar' ], 4)\nconsole.log(obj.foo.bar) // =\u003e 4\n```\n\n### `function toTokens(path: string): Array\u003cstring\u003e`\n\nConvert a JSON Pointer string to a list of unescaped accessor tokens.\n\n```js\nimport { toTokens } from 'pointer-props'\ntoTokens('/a~1b/c~0d') // =\u003e [ \"a/b\", \"c~d\" ]\n```\n\n### `function toPointer(list: ArrayLike\u003cstring | number\u003e): string`\n\nConvert a list of unescaped accessor tokens into a JSON Pointer string.\n\n```js\nimport { toPointer } from 'pointer-props'\ntoPointer([ 'a/b', 'c~d' ]) // =\u003e \"/a~1b/c~0d\"\n```\n\n### `export function resolve\u003cT extends object\u003e(obj: T, path: string | ArrayLike\u003cstring | number\u003e): ArrayLike\u003cstring | number\u003e`\n\nGiven a JSON Pointer string and an object potentially containing [JSON References](https://datatracker.ietf.org/doc/html/draft-pbryan-zyp-json-ref-03) (e.g. `$ref`), resolve all references and return the final path.\n\n```js\nimport { resolve } from 'pointer-props'\nconst obj = {\n\tfoo: { $ref: '#/bar' },\n\tbar: { $ref: '#/fizz' },\n\tfizz: { $ref: '#/buzz' },\n\tbuzz: 3\n}\nresolve('#/foo') // =\u003e [ 'buzz' ]\n```\n\n## License\n\nPublished and released under the [Very Open License](http://veryopenlicense.com).\n\nIf you need a commercial license, [contact me here](https://davistobias.com/license?software=pointer-props).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsaibotsivad%2Fpointer-props","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsaibotsivad%2Fpointer-props","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsaibotsivad%2Fpointer-props/lists"}