{"id":19746760,"url":"https://github.com/nikaple/uni-flatten","last_synced_at":"2025-04-30T08:31:44.236Z","repository":{"id":185232138,"uuid":"673217561","full_name":"Nikaple/uni-flatten","owner":"Nikaple","description":"Flattens a nested object, or convert it back **perfectly**.","archived":false,"fork":false,"pushed_at":"2024-11-11T19:44:28.000Z","size":1158,"stargazers_count":6,"open_issues_count":10,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-11-11T20:30:31.420Z","etag":null,"topics":[],"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/Nikaple.png","metadata":{"files":{"readme":"README.md","changelog":"changelog.md","contributing":"CONTRIBUTING.md","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":"2023-08-01T06:21:02.000Z","updated_at":"2024-11-03T18:38:06.000Z","dependencies_parsed_at":"2024-01-03T02:45:47.748Z","dependency_job_id":"3a60c423-e569-464d-8054-7932cd6bb0ce","html_url":"https://github.com/Nikaple/uni-flatten","commit_stats":null,"previous_names":["nikaple/uni-flatten"],"tags_count":17,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Nikaple%2Funi-flatten","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Nikaple%2Funi-flatten/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Nikaple%2Funi-flatten/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Nikaple%2Funi-flatten/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Nikaple","download_url":"https://codeload.github.com/Nikaple/uni-flatten/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224202778,"owners_count":17272807,"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":[],"created_at":"2024-11-12T02:15:48.278Z","updated_at":"2024-11-12T02:15:48.776Z","avatar_url":"https://github.com/Nikaple.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003eUni-flatten\u003c/h1\u003e\n\n\u003cp align=\"center\"\u003e\n\u003ca href=\"https://www.npmjs.com/package/uni-flatten\"\u003e\u003cimg src=\"https://img.shields.io/npm/v/uni-flatten.svg\" alt=\"NPM Version\" /\u003e\u003c/a\u003e\n\u003ca href=\"https://www.npmjs.com/package/uni-flatten\"\u003e\u003cimg src=\"https://img.shields.io/npm/l/uni-flatten.svg\" alt=\"Package License\" /\u003e\u003c/a\u003e\n\u003ca href=\"https://www.npmjs.com/package/uni-flatten\"\u003e\u003cimg src=\"https://img.shields.io/npm/dm/uni-flatten.svg\" alt=\"NPM Downloads\" /\u003e\u003c/a\u003e\n\u003ca href=\"https://github.com/Nikaple/uni-flatten/actions/workflows/build.yml\"\u003e\u003cimg src=\"https://github.com/Nikaple/uni-flatten/workflows/build/badge.svg\" alt=\"build\" /\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n## Features\n\n## Installation\n\n```bash\n$ npm i --save uni-flatten\n```\n\n## Inspiration\n\nThere are various popular modules to flatten an object, but they lost context such as numeric keys, dot in object key, special characters etc. These behaviors disabled converting flattened object to original object. This is when `uni-flatten` becomes handy.\n\n## Quick Start\n\n### Flatten a nested object\n\n```ts\nimport { flatten } from 'uni-flatten';\n\nflatten({\n  a: {\n    b: {\n      c: 123,\n    },\n    d: [\n      {\n        e: { f: 456 },\n      },\n    ],\n  },\n  'a.b.c': 789,\n});\n/*\nresult:\n{\n  'a.b.c': 123, // normal nested object\n  'a.d[0].e.f': 456, // nested object array, use brackets to represent array index\n  '[\"a.b.c\"]': 789, // object with special character in keys\n},\n*/\n```\n\n### Unflatten a flat object\n\n```ts\nimport { unflatten } from 'uni-flatten';\n\nunflatten({\n  'a.b.c': 123, // normal nested object\n  'a.d[0].e.f': 456, // nested object array, use brackets to represent array index\n  '[\"a.b.c\"]': 789, // object with special character in keys\n});\n/*\nresult:\n{\n  a: {\n    b: {\n      c: 123,\n    },\n    d: [\n      {\n        e: { f: 456 },\n      },\n    ],\n  },\n  'a.b.c': 789,\n}\n*/\n```\n\n### Flatten a cyclic object\n\nCircular references are serialized as `[Circular-\u003e\"\u003cpath\u003e\"]` when flattened, which is useful for unflattening.\n\n```ts\nimport { flatten, unflatten } from 'uni-flatten';\n\nconst obj = { a: { b: { c: 1 } } };\nobj.a.d = obj.a;\nconst flattened = flatten(obj); // { 'a.b.c': 1, 'a.d': '[Circular-\u003e\"a\"]' }\nconst restored = unflatten(obj); // { a: \u003cref *1\u003e { b: { c: 1 }, d: [Circular *1] }\n```\n\n## API\n\nPlease refer to our [API website](https://nikaple.github.io/uni-flatten) for full documentation.\n\n## Changelog\n\nPlease refer to [changelog.md](https://github.com/Nikaple/uni-flatten/blob/main/changelog.md)\n\n## License\n\n[MIT](LICENSE).\n\n## Star History\n\n[![Star History Chart](https://api.star-history.com/svg?repos=Nikaple/uni-flatten\u0026type=Date)](https://star-history.com/#Nikaple/uni-flatten\u0026Date)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnikaple%2Funi-flatten","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnikaple%2Funi-flatten","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnikaple%2Funi-flatten/lists"}