{"id":13678605,"url":"https://github.com/g-makarov/dot-path-value","last_synced_at":"2025-04-29T15:32:12.178Z","repository":{"id":65388484,"uuid":"591400290","full_name":"g-makarov/dot-path-value","owner":"g-makarov","description":"Safely get and set deep nested properties using dot notation.","archived":false,"fork":false,"pushed_at":"2024-09-22T14:41:03.000Z","size":171,"stargazers_count":340,"open_issues_count":6,"forks_count":6,"subscribers_count":5,"default_branch":"main","last_synced_at":"2024-11-07T23:46:10.974Z","etag":null,"topics":["access","array","change","deep","dot","get","notation","object","path","property","set","type","typescript","update","value"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/g-makarov.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":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-01-20T17:02:43.000Z","updated_at":"2024-10-25T10:17:10.000Z","dependencies_parsed_at":"2024-02-09T13:47:13.122Z","dependency_job_id":"91812c5b-3323-436f-b3b3-aa2c688419ae","html_url":"https://github.com/g-makarov/dot-path-value","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/g-makarov%2Fdot-path-value","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/g-makarov%2Fdot-path-value/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/g-makarov%2Fdot-path-value/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/g-makarov%2Fdot-path-value/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/g-makarov","download_url":"https://codeload.github.com/g-makarov/dot-path-value/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224178963,"owners_count":17268980,"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":["access","array","change","deep","dot","get","notation","object","path","property","set","type","typescript","update","value"],"created_at":"2024-08-02T13:00:55.960Z","updated_at":"2024-11-11T21:30:51.737Z","avatar_url":"https://github.com/g-makarov.png","language":"TypeScript","funding_links":["https://www.buymeacoffee.com/gmakarov"],"categories":["🗂️ Use Cases","TypeScript"],"sub_categories":["dot-path-value"],"readme":"# dot-path-value\n\nSafely get and set deep nested properties using dot notation.\n\n\u003ca href=\"https://www.npmjs.com/package/dot-path-value\"\u003e\n  \u003cimg alt=\"npm version\" src=\"https://img.shields.io/npm/v/dot-path-value.svg?style=flat-square\" /\u003e\n\u003c/a\u003e\n\u003ca href=\"https://www.npmjs.com/package/dot-path-value\"\u003e\n  \u003cimg alt=\"npm downloads\" src=\"https://img.shields.io/npm/dm/dot-path-value.svg?style=flat-square\" /\u003e\n\u003c/a\u003e\n\u003ca href=\"https://bundlephobia.com/package/dot-path-value\"\u003e\n  \u003cimg alt=\"npm minified bundle size\" src=\"https://img.shields.io/bundlephobia/min/dot-path-value?style=flat-square\"\u003e\n\u003c/a\u003e\n\u003ca href=\"https://bundlephobia.com/package/dot-path-value\"\u003e\n  \u003cimg alt=\"npm gzip minified bundle size\" src=\"https://img.shields.io/bundlephobia/minzip/dot-path-value?style=flat-square\"\u003e\n\u003c/a\u003e\n\u003ca href=\"https://github.com/g-makarov/dot-path-value\"\u003e\n  \u003cimg alt=\"npm gzip minified bundle size\" src=\"https://img.shields.io/github/stars/g-makarov/dot-path-value?style=flat-square\"\u003e\n\u003c/a\u003e\n\n## Features\n\n- TypeScript first 🤙\n- Support arrays\n- Tiny\n- No dependencies\n- Utility types `Path` and `PathValue`\n\nIf you find this library useful, why not\n\n\u003ca href=\"https://www.buymeacoffee.com/gmakarov\" target=\"_blank\"\u003e\u003cimg src=\"https://cdn.buymeacoffee.com/buttons/v2/default-yellow.png\" alt=\"Buy Me A Coffee\" width=\"160\" height=\"40\"\u003e\u003c/a\u003e\n\n## Installation\n\n```bash\n# using npm\nnpm install dot-path-value\n# using pnpm\npnpm install dot-path-value\n# using yarn\nyarn add dot-path-value\n```\n\n## Usage\n\n```ts\nimport { getByPath, setByPath } from 'dot-path-value';\n\nconst obj = {\n  a: {\n    b: 'hello',\n    d: [\n      {\n        e: 'world',\n      }\n    ],\n  },\n};\n\n// access through object\ngetByPath(obj, 'a.b'); // outputs 'hello' with type `string`\n\n// access through array\ngetByPath(obj, 'a.d.0.e'); // outputs 'world' with type `string`\ngetByPath(obj, 'a.d.0'); // outputs '{ e: 'world' }' with type `{ e: string }`\n\n// also you can pass array as first argument\ngetByPath([{ a: 1 }], '0.a'); // outputs '1' with type `number`\n\n// typescript errors\ngetByPath(obj, 'a.b.c'); // `c` property does not exist\n\n\n// set a property through an object\nsetByPath(obj, 'a.b', 'hello there');\n```\n\n## Types\n\n`dot-path-value` exports a few types to ensure the type safety:\n\n| Type                  | Description                                                                               |\n| --------------------- | ----------------------------------------------------------------------------------------- |\n| `Path\u003cT\u003e`             | converts nested structure `T` into a string representation of the paths to its properties |\n| `PathValue\u003cT, TPath\u003e` | returns the type of the value at the specified path                                       |\n\n### Types usage\n\n```ts\nimport { Path, PathValue } from 'dot-path-value';\n\nconst obj = {\n  a: {\n    b: 'hello',\n    d: [\n      {\n        e: 'world',\n      }\n    ],\n  },\n};\n\ntype Foo = Path\u003ctypeof obj\u003e; // 'a.d' | 'a' | 'a.b' | `a.d.${number}` | `a.d.${number}.e`\ntype Bar = PathValue\u003ctypeof obj, 'a.b'\u003e; // 'string'\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fg-makarov%2Fdot-path-value","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fg-makarov%2Fdot-path-value","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fg-makarov%2Fdot-path-value/lists"}