{"id":16703515,"url":"https://github.com/kolengri/easy-tsnameof","last_synced_at":"2025-04-05T04:26:59.199Z","repository":{"id":42839768,"uuid":"263825399","full_name":"kolengri/easy-tsnameof","owner":"kolengri","description":"🍫 Make nameof in typescript sweet again! Type safe your interface path","archived":false,"fork":false,"pushed_at":"2025-02-10T11:42:38.000Z","size":1031,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-12T15:41:50.592Z","etag":null,"topics":["nameof","nameof-operator","typescript"],"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/kolengri.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}},"created_at":"2020-05-14T05:40:13.000Z","updated_at":"2025-02-10T11:41:42.000Z","dependencies_parsed_at":"2023-02-07T20:00:29.008Z","dependency_job_id":null,"html_url":"https://github.com/kolengri/easy-tsnameof","commit_stats":null,"previous_names":[],"tags_count":21,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kolengri%2Feasy-tsnameof","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kolengri%2Feasy-tsnameof/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kolengri%2Feasy-tsnameof/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kolengri%2Feasy-tsnameof/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kolengri","download_url":"https://codeload.github.com/kolengri/easy-tsnameof/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247289447,"owners_count":20914463,"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":["nameof","nameof-operator","typescript"],"created_at":"2024-10-12T19:08:34.637Z","updated_at":"2025-04-05T04:26:59.184Z","avatar_url":"https://github.com/kolengri.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Easy Typescript NameOf\n\n\u003cp\u003e\n  \u003ca href=\"https://www.npmjs.com/package/easy-tsnameof\"\u003e\n    \u003cimg height=\"20px\" src=\"https://badgen.net/npm/license/easy-tsnameof\" /\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://www.npmjs.com/package/easy-tsnameof\"\u003e\n    \u003cimg height=\"20px\" src=\"https://badgen.net/npm/v/easy-tsnameof\" /\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://www.npmjs.com/package/easy-tsnameof\"\u003e\n    \u003cimg height=\"20px\" src=\"https://badgen.net/npm/dependents/easy-tsnameof\" /\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://www.npmjs.com/package/easy-tsnameof\"\u003e\n    \u003cimg height=\"20px\" src=\"https://badgen.net/npm/types/easy-tsnameof\" /\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://github.com/kolengri/easy-tsnameof#readme\"\u003e\n    \u003cimg height=\"20px\" src=\"https://badgen.net/github/issues/kolengri/easy-tsnameof\" /\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://bundlephobia.com/result?p=easy-tsnameof\"\u003e\n    \u003cimg height=\"20px\" src=\"https://badgen.net/bundlephobia/min/easy-tsnameof\" /\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://bundlephobia.com/result?p=easy-tsnameof\"\u003e\n    \u003cimg height=\"20px\" src=\"https://badgen.net/bundlephobia/minzip/easy-tsnameof\" /\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\n## Install\n\n```bash\nyarn add easy-tsnameof\n```\n\n```bash\nnpm install easy-tsnameof\n```\n\n## How to use?\n\n```ts\nimport nameOf from 'easy-tsnameof';\n\ntype NameOfTest = {\n  test1: {\n    test2: {\n      test3: string;\n    };\n  };\n};\nnameOf\u003cNameOfTest\u003e((o) =\u003e o.test1.test2.test3);\n// test1.test2.test3\n\nnameOf\u003cNameOfTest\u003e('test1');\n// test1\n\nnameOf\u003cNameOfTest, never\u003e().test1.test2.test3.$path;\n// test1.test2.test3\n```\n\n## Fabrics\n\n```ts\nimport { nameOf } from 'easy-tsnameof';\n\ntype NameOfTest = {\n  test1: {\n    test2: {\n      test3: string;\n    };\n  };\n};\nconst f = nameOf\u003cNameOfTest, never\u003e();\nf.test1.test2.test3.$path;\n// test1.test2.test3\n```\n\n## Working with arrays\n\n```ts\nimport { nameOf } from 'easy-tsnameof';\n\ntype NameOfTest = {\n  test1: {\n    test2: {\n      test: string;\n    };\n    test3: { test4: number }[];\n  };\n};\nconst f = nameOf\u003cNameOfTest, never\u003e();\nconst index = 999;\n\nf.test1.test3[index].test4.$path;\n// test1.test3[999].test4\n```\n\n## Path access methods\n\n### .$path\n\nAccess to path string:\n\n```ts\nnameOf\u003cTestType, never\u003e().a.b.c.d.$path;\n// \"a.b.c.d\"\n```\n\n[@m-abboud](https://github.com/m-abboud)\n\n### .$rawPath\n\nAccess to raw path array\n\nType: `(string | number | Symbol)[]`\n\n```ts\nnameOf\u003cTestType, never\u003e().a.b[5].c.d.$rawPath;\n// [\"a\", \"b\", 5, \"c\", \"d\"]\n```\n\nThe `$rawPath` is something that you might want to use with the following methods from\nRamda, to add type safety on the path:\n\n- [R.assocPath](https://ramdajs.com/docs/#assocPath),\n- [R.dissocPath](https://ramdajs.com/docs/#dissocPath),\n- [R.hasPath](https://ramdajs.com/docs/#hasPath),\n- [R.path](https://ramdajs.com/docs/#path),\n- [R.pathEq](https://ramdajs.com/docs/#pathEq),\n- [R.pathOr](https://ramdajs.com/docs/#pathOr),\n- [R.paths](https://ramdajs.com/docs/#paths),\n- [R.lensPath](https://ramdajs.com/docs/#lensPath)\n\n## Inspired by\n\n- [typed-path](https://github.com/bsalex/typed-path)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkolengri%2Feasy-tsnameof","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkolengri%2Feasy-tsnameof","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkolengri%2Feasy-tsnameof/lists"}