{"id":13516279,"url":"https://github.com/lukeed/nestie","last_synced_at":"2025-04-05T14:09:19.899Z","repository":{"id":51763516,"uuid":"293955792","full_name":"lukeed/nestie","owner":"lukeed","description":"A tiny (215B) and fast utility to expand a flattened object","archived":false,"fork":false,"pushed_at":"2023-04-26T14:34:32.000Z","size":27,"stargazers_count":202,"open_issues_count":3,"forks_count":6,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-29T13:11:12.187Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/lukeed.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","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},"funding":{"github":"lukeed"}},"created_at":"2020-09-09T00:02:09.000Z","updated_at":"2024-12-28T17:56:13.000Z","dependencies_parsed_at":"2024-01-13T19:25:58.746Z","dependency_job_id":"933b413a-3244-4233-8358-8a02d391ee1c","html_url":"https://github.com/lukeed/nestie","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lukeed%2Fnestie","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lukeed%2Fnestie/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lukeed%2Fnestie/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lukeed%2Fnestie/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lukeed","download_url":"https://codeload.github.com/lukeed/nestie/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247345854,"owners_count":20924102,"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-08-01T05:01:20.998Z","updated_at":"2025-04-05T14:09:19.881Z","avatar_url":"https://github.com/lukeed.png","language":"JavaScript","funding_links":["https://github.com/sponsors/lukeed"],"categories":["JavaScript"],"sub_categories":[],"readme":"# nestie [![CI](https://github.com/lukeed/nestie/workflows/CI/badge.svg)](https://github.com/lukeed/nestie/actions) [![codecov](https://badgen.now.sh/codecov/c/github/lukeed/nestie)](https://codecov.io/gh/lukeed/nestie)\n\n\u003e A tiny (215B) and [fast](#benchmarks) utility to expand a flattened object\n\nThis module expands an Object who's keys are delimited/condensed representatives of multiple levels.\n\nBy default, the `.` character is used as a delimiter. This is customizable. \u003cbr\u003eKeys are split using the delimiter, each signifying a new level/depth.\n\n\n## Install\n\n```\n$ npm install --save nestie\n```\n\n\n## Usage\n\n\u003e Please see [Keys](#keys) for pathing options\n\n```js\nimport { nestie } from 'nestie';\n\nnestie({\n  'a': 'hi',\n  'b.b.0': 'foo',\n  'b.b.1': '',\n  'b.b.3': 'bar',\n  'b.d': 'hello',\n  'b.e.a': 'yo',\n  'b.e.b': null,\n  'b.e.c': 'sup',\n  'b.e.d': 0,\n  'b.e.f.0.foo': 123,\n  'b.e.f.0.bar': 123,\n  'b.e.f.1.foo': 465,\n  'b.e.f.1.bar': 456,\n  'c': 'world'\n});\n//=\u003e {\n//=\u003e   a: 'hi',\n//=\u003e   b: {\n//=\u003e     b: ['foo', '', , 'bar'],\n//=\u003e     d: 'hello',\n//=\u003e     e: {\n//=\u003e       a: 'yo',\n//=\u003e       b: null,\n//=\u003e       c: 'sup',\n//=\u003e       d: 0,\n//=\u003e       f: [\n//=\u003e         { foo: 123, bar: 123 },\n//=\u003e         { foo: 465, bar: 456 },\n//=\u003e       ]\n//=\u003e     }\n//=\u003e   },\n//=\u003e   c: 'world'\n//=\u003e }\n```\n\n## Keys\n\nHere are additional examples using different key-notation combinations in order represent different Array/Object structures.\n\n```js\nnestie({\n  'hello.there': 123,\n  'hello.world': 456,\n});\n//=\u003e {\n//=\u003e   hello: {\n//=\u003e     there: 123,\n//=\u003e     world: 456\n//=\u003e   }\n//=\u003e }\n\nnestie({\n  'foo.0.bar': 1,\n  'foo.1': 'hello',\n  'foo.2.bar': 3,\n});\n//=\u003e {\n//=\u003e   foo: [\n//=\u003e     { bar: 1 },\n//=\u003e     'hello',\n//=\u003e     { bar: 3 }\n//=\u003e   ]\n//=\u003e }\n\nnestie({\n  '0.0': 'foo',\n  '0.1': 'bar',\n  '1.foo.bar': 123,\n  '1.foo.baz.0': 4,\n  '1.foo.baz.1': 5,\n  '1.foo.baz.2': 6,\n  '1.hello': 'world',\n  '2': 'howdy'\n});\n//=\u003e [\n//=\u003e   ['foo', 'bar'],\n//=\u003e   {\n//=\u003e     foo: {\n//=\u003e       bar: 123,\n//=\u003e       baz: [4, 5, 6]\n//=\u003e     },\n//=\u003e     hello: 'world'\n//=\u003e   },\n//=\u003e   'howdy'\n//=\u003e ]\n```\n\n## API\n\n### nestie(input, delimiter?)\nReturns: `Object` or `Array`\n\nReturns a new Object or Array, depending on the keys.\n\n\u003e **Note:** A `null` or `undefined` input will return `undefined`~!\n\n#### input\nType: `Object`\n\nThe object to expand.\n\n#### delimiter\nType: `String`\u003cbr\u003e\nDefault: `.`\n\nThe \"glue\" used to join multi-level keys together. \u003cbr\u003e\nKeys will be split using this `delimiter` string, signifying a new level/depth.\n\n```js\nconst input = {\n  'foo.bar': 123,\n  'hello_world': 456,\n};\n\nnestie(input);\n//=\u003e {\n//=\u003e   foo: { bar: 123 },\n//=\u003e   hello_world: 456,\n//=\u003e }\n\nnestie(input, '_');\n//=\u003e {\n//=\u003e   'foo.bar': 123,\n//=\u003e   hello: { world: 456 },\n//=\u003e }\n```\n\n\n## Benchmarks\n\n\u003e Running on Node.js v18.12.1\n\n\u003e **Note:** The `≠` denotes that the candidate has a different API and is not a direct comparison.\n\n```\nLoad Time:\n  dset         0.421ms\n  lodash/set   5.472ms\n  flat         0.926ms\n  nestie       0.131ms\n\nValidation:\n  ✘ lodash/set ≠ (FAILED) @ \"array w/ holes\"\n  ✘ dset ≠ (FAILED) @ \"array w/ holes\"\n  ✔ flat.unflatten\n  ✔ nestie\n\nBenchmark:\n  lodash/set ≠     x 365,431 ops/sec ±0.46% (96 runs sampled)\n  dset ≠           x 528,696 ops/sec ±0.12% (99 runs sampled)\n  flat.unflatten   x 235,161 ops/sec ±0.16% (98 runs sampled)\n  nestie           x 565,665 ops/sec ±0.13% (99 runs sampled)\n```\n\n\n## Related\n\n* [flattie](https://github.com/lukeed/flattie) – flatten an object using customizable glue in 187 bytes \u003cbr\u003e_This is `nestie`'s reverse / counterpart._\n* [dset](https://github.com/lukeed/dset) – safely write deep Object values in 160 bytes\n* [dlv](https://github.com/developit/dlv) – safely read from deep properties in 120 bytes\n\n\n## License\n\nMIT © [Luke Edwards](https://lukeed.com)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flukeed%2Fnestie","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flukeed%2Fnestie","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flukeed%2Fnestie/lists"}