{"id":27129241,"url":"https://github.com/roonie007/flatten","last_synced_at":"2026-05-01T13:31:18.103Z","repository":{"id":57675577,"uuid":"429228176","full_name":"roonie007/flatten","owner":"roonie007","description":"Flatten or unflatten a nested Javascript object by delimiter keys.","archived":false,"fork":false,"pushed_at":"2022-04-17T13:59:21.000Z","size":5,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-03-12T07:49:08.866Z","etag":null,"topics":["deno","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/roonie007.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":"2021-11-17T23:07:48.000Z","updated_at":"2021-12-15T20:59:07.000Z","dependencies_parsed_at":"2022-09-26T20:41:36.394Z","dependency_job_id":null,"html_url":"https://github.com/roonie007/flatten","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/roonie007/flatten","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/roonie007%2Fflatten","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/roonie007%2Fflatten/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/roonie007%2Fflatten/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/roonie007%2Fflatten/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/roonie007","download_url":"https://codeload.github.com/roonie007/flatten/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/roonie007%2Fflatten/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32499681,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-30T13:12:12.517Z","status":"online","status_checked_at":"2026-05-01T02:00:05.856Z","response_time":64,"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":["deno","typescript"],"created_at":"2025-04-07T19:31:07.816Z","updated_at":"2026-05-01T13:31:18.082Z","avatar_url":"https://github.com/roonie007.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Flatten\n\nFlatten or unflatten a nested Javascript object by delimiter keys.\n\n## Usage\n\n### Flatten\n\n```javascript\nimport { flatten } from \"https://deno.land/x/flatten/mod.ts\";\n\nconst obj = {\n  key1: {\n    keyA: \"valueI\",\n  },\n  key2: {\n    keyB: \"valueII\",\n  },\n  key3: { a: { b: { c: 2 } } },\n  arr: [\"item1\", null, [\"nested1\", \"nested2\"]],\n};\n\nflatten(obj);\n// {\n//   \"key1.keyA\": \"valueI\",\n//   \"key2.keyB\": \"valueII\",\n//   \"key3.a.b.c\": 2,\n//   \"arr.0\": \"item1\",\n//   \"arr.1\": null,\n//   \"arr.2.0\": \"nested1\",\n//   \"arr.2.1\": \"nested2\",\n//   \"arr.3.key4.nested\": 1,\n//   \"arr.3.key5\": undefined\n// }\n\nflatten(obj, { flattenArray: false });\n// {\n//   \"key1.keyA\": \"valueI\",\n//   \"key2.keyB\": \"valueII\",\n//   \"key3.a.b.c\": 2,\n//   arr: [\n//     \"item1\",\n//     null,\n//     [ \"nested1\", \"nested2\" ],\n//     { key4: { nested: 1 }, key5: undefined }\n//   ]\n// }\n\nflatten(obj, { delimiter: \"--\" });\n// {\n//   \"key1--keyA\": \"valueI\",\n//   \"key2--keyB\": \"valueII\",\n//   \"key3--a--b--c\": 2,\n//   \"arr--0\": \"item1\",\n//   \"arr--1\": null,\n//   \"arr--2--0\": \"nested1\",\n//   \"arr--2--1\": \"nested2\",\n//   \"arr--3--key4--nested\": 1,\n//   \"arr--3--key5\": undefined\n// }\n\nflatten(obj, ignoreIfProperty: [\"key3\"]);\n// Since key3 is an ignored property b, then it will not be flattened\n// {\n//   \"key1.keyA\": \"valueI\",\n//   \"key2.keyB\": \"valueII\",\n//   \"key3\": { a: { b: { c: 2 } } },\n//   \"arr.0\": \"item1\",\n//   \"arr.1\": null,\n//   \"arr.2.0\": \"nested1\",\n//   \"arr.2.1\": \"nested2\",\n//   \"arr.3.key4.nested\": 1,\n//   \"arr.3.key5\": undefined\n// }\n\nflatten(obj, ignoreIfContainsProperty: [\"b\"]);\n// Since key3.a contains an ignored property \"b\", then it will not be flattened\n// {\n//   \"key1.keyA\": \"valueI\",\n//   \"key2.keyB\": \"valueII\",\n//   \"key3.a\": { b: { c: 2 } },\n//   \"arr.0\": \"item1\",\n//   \"arr.1\": null,\n//   \"arr.2.0\": \"nested1\",\n//   \"arr.2.1\": \"nested2\",\n//   \"arr.3.key4.nested\": 1,\n//   \"arr.3.key5\": undefined\n// }\n\n```\n\n#### Options\n\nis an object composed of\n\n**delimiter: _string_** (default = '.')  \nUse a custom delimiter instead of `.` when flattening your objects.\n\n**flattenArray: _boolean_** (default = true)  \nFlatten the arrays and their items.\n\n### Unflatten\n\n```javascript\nimport { unflatten } from \"https://deno.land/x/flatten/mod.ts\";\n\nconst flattedObj = {\n  \"key1.keyA\": \"valueI\",\n  \"key2.keyB\": \"valueII\",\n  \"key3.a.b.c\": 2,\n  \"arr.0\": \"item1\",\n  \"arr.1\": null,\n  \"arr.2.0\": \"nested1\",\n  \"arr.2.1\": \"nested2\",\n  \"arr.3.key4.nested\": 1,\n  \"arr.3.key5\": undefined,\n};\n\nunflatten(flattedObj);\n// {\n//   key1: {\n//       keyA: 'valueI'\n//   },\n//   key2: {\n//       keyB: 'valueII'\n//   },\n//   key3: { a: { b: { c: 2 } } },\n//   arr: ['item1',null,['nested1', 'nested2']]\n// }\n\nconst flattedObjWithDoubleDashes = {\n  \"key1--keyA\": \"valueI\",\n  \"key2--keyB\": \"valueII\",\n  \"key3--a--b--c\": 2,\n  \"arr--0\": \"item1\",\n  \"arr--1\": null,\n  \"arr--2--0\": \"nested1\",\n  \"arr--2--1\": \"nested2\",\n  \"arr--3--key4--nested\": 1,\n  \"arr--3--key5\": undefined,\n};\n\nunflatten(flattedObjWithDoubleDashes, \"--\");\n// {\n//   key1: {\n//       keyA: 'valueI'\n//   },\n//   key2: {\n//       keyB: 'valueII'\n//   },\n//   key3: { a: { b: { c: 2 } } },\n//   arr: ['item1',null,['nested1', 'nested2']]\n// }\n```\n\n#### Options\n\n**delimiter: _string_** (default = '.')  \nUse a custom delimiter instead of `.` when flattening your objects.\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Froonie007%2Fflatten","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Froonie007%2Fflatten","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Froonie007%2Fflatten/lists"}