{"id":13472373,"url":"https://github.com/lukeed/klona","last_synced_at":"2025-05-13T20:15:49.884Z","repository":{"id":40643702,"uuid":"232771595","full_name":"lukeed/klona","owner":"lukeed","description":"A tiny (240B to 501B) and fast utility to \"deep clone\" Objects, Arrays, Dates, RegExps, and more!","archived":false,"fork":false,"pushed_at":"2024-08-11T13:49:32.000Z","size":100,"stargazers_count":1667,"open_issues_count":13,"forks_count":45,"subscribers_count":12,"default_branch":"master","last_synced_at":"2025-05-13T16:53:47.521Z","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,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"lukeed"}},"created_at":"2020-01-09T09:27:47.000Z","updated_at":"2025-05-12T07:31:33.000Z","dependencies_parsed_at":"2024-11-05T19:02:50.020Z","dependency_job_id":"f5952d45-40d1-4eac-96c3-2a2643dd74e3","html_url":"https://github.com/lukeed/klona","commit_stats":{"total_commits":99,"total_committers":9,"mean_commits":11.0,"dds":0.09090909090909094,"last_synced_commit":"e563341d88f433e74a9b4c3c0372d4ba55d2f79e"},"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lukeed%2Fklona","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lukeed%2Fklona/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lukeed%2Fklona/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lukeed%2Fklona/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lukeed","download_url":"https://codeload.github.com/lukeed/klona/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254020640,"owners_count":22000756,"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-07-31T16:00:54.145Z","updated_at":"2025-05-13T20:15:49.855Z","avatar_url":"https://github.com/lukeed.png","language":"JavaScript","funding_links":["https://github.com/sponsors/lukeed"],"categories":["JavaScript","Packages","others","🔧 Utilities \u0026 Miscellaneous","Utilities"],"sub_categories":["Utility","Data Structures"],"readme":"\u003cdiv align=\"center\"\u003e\n  \u003cimg src=\"logo.png\" alt=\"klona\" height=\"100\" /\u003e\n\u003c/div\u003e\n\n\u003cdiv align=\"center\"\u003e\n  \u003ca href=\"https://npmjs.org/package/klona\"\u003e\n    \u003cimg src=\"https://badgen.now.sh/npm/v/klona\" alt=\"version\" /\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://github.com/lukeed/klona/actions\"\u003e\n    \u003cimg src=\"https://github.com/lukeed/klona/workflows/CI/badge.svg\" alt=\"CI\" /\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://licenses.dev/npm/klona\"\u003e\n    \u003cimg src=\"https://licenses.dev/b/npm/klona\" alt=\"licenses\" /\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://npmjs.org/package/klona\"\u003e\n    \u003cimg src=\"https://badgen.now.sh/npm/dm/klona\" alt=\"downloads\" /\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://codecov.io/gh/lukeed/klona\"\u003e\n    \u003cimg src=\"https://codecov.io/gh/lukeed/klona/branch/master/graph/badge.svg?token=8ej0WeKqz7\" alt=\"codecov\" /\u003e\n  \u003c/a\u003e\n\u003c/div\u003e\n\n\u003cdiv align=\"center\"\u003eA tiny (240B to 501B) and fast utility to \"deep clone\" Objects, Arrays, Dates, RegExps, and more!\u003c/div\u003e\n\n\n## Features\n\n* Super tiny and [performant](#benchmarks)\n* Deep clone / recursive copies\n* Safely handles complex data types\u003cbr\u003e\n    _Array, Date, Map, Object, RegExp, Set, TypedArray, and more_\n\nUnlike a \"shallow copy\" (eg, `Object.assign`), a \"deep clone\" recursively traverses a source input and copies its _values_ \u0026mdash; instead of _references_ to its values \u0026mdash; into a new instance of that input. The result is a structurally equivalent clone that operates independently of the original source and controls its own values.\n\n\u003e **Why \"klona\"?** It's \"clone\" in Swedish.\u003cbr\u003e\n\u003e **What's with the sheep?** [Dolly](https://en.wikipedia.org/wiki/Dolly_(sheep)).\n\n\n## Install\n\n```\n$ npm install --save klona\n```\n\n\n## Modes\n\nThere are multiple \"versions\" of `klona` available, which allows you to bring only the functionality you need!\n\n#### `klona/json`\n\u003e **Size (gzip):** 240 bytes\u003cbr\u003e\n\u003e **Availability:** [CommonJS](https://unpkg.com/klona/json/index.js), [ES Module](https://unpkg.com/klona/json/index.mjs), [UMD](https://unpkg.com/klona/json/index.min.js)\u003cbr\u003e\n\u003e **Ability:** JSON data types\n\n```js\nimport { klona } from 'klona/json';\n```\n\n#### `klona/lite`\n\u003e **Size (gzip):** 354 bytes\u003cbr\u003e\n\u003e **Availability:** [CommonJS](https://unpkg.com/klona/lite/index.js), [ES Module](https://unpkg.com/klona/lite/index.mjs), [UMD](https://unpkg.com/klona/lite/index.min.js)\u003cbr\u003e\n\u003e **Ability:** extends `klona/json` with support for custom class, Date, and RegExp\n\n```js\nimport { klona } from 'klona/lite';\n```\n\n#### `klona`\n\u003e **Size (gzip):** 451 bytes\u003cbr\u003e\n\u003e **Availability:** [CommonJS](https://unpkg.com/klona/dist/index.js), [ES Module](https://unpkg.com/klona/dist/index.mjs), [UMD](https://unpkg.com/klona/dist/index.min.js)\u003cbr\u003e\n\u003e **Ability:** extends `klona/lite` with support for Map, Set, DataView, ArrayBuffer, TypedArray\n\n```js\nimport { klona } from 'klona';\n```\n\n#### `klona/full`\n\u003e **Size (gzip):** 501 bytes\u003cbr\u003e\n\u003e **Availability:** [CommonJS](https://unpkg.com/klona/full/index.js), [ES Module](https://unpkg.com/klona/full/index.mjs), [UMD](https://unpkg.com/klona/full/index.min.js)\u003cbr\u003e\n\u003e **Ability:** extends `klona` with support for Symbol properties and non-enumerable properties\n\n```js\nimport { klona } from 'klona/full';\n```\n\n\n## Usage\n\n```js\nimport { klona } from 'klona';\n\nconst input = {\n  foo: 1,\n  bar: {\n    baz: 2,\n    bat: {\n      hello: 'world'\n    }\n  }\n};\n\nconst output = klona(input);\n\n// exact copy of original\nassert.deepStrictEqual(input, output);\n\n// applying deep updates...\noutput.bar.bat.hola = 'mundo';\noutput.bar.baz = 99;\n\n// ...doesn't affect source!\nconsole.log(\n  JSON.stringify(input, null, 2)\n);\n// {\n//   \"foo\": 1,\n//   \"bar\": {\n//     \"baz\": 2,\n//     \"bat\": {\n//       \"hello\": \"world\"\n//     }\n//   }\n// }\n```\n\n\n## API\n\n### klona(input)\nReturns: `typeof input`\n\nReturns a deep copy/clone of the input.\n\n\n## Benchmarks\n\n\u003e Running Node v12.18.3\n\nThe benchmarks can be found in the [`/bench`](/bench) directory. They are separated into multiple categories:\n\n* `JSON` – compares an array of objects comprised of JSON data types (`String`, `Number`, `null`, `Array`, `Object`)\n* `LITE` – like `JSON`, but adds `RegExp`, `Date` and `undefined` values\n* `DEFAULT` – object with `RegExp`, `Date`, `Array`, `Map`, `Set`, custom class, `Int8Array`, `DataView`, `Buffer` values\n* `FULL` – like `DEFAULT`, but adds `Symbol` and non-enumerable properties\n\n\u003e **Important:** Only candidates that pass validation step(s) are listed. \u003cbr\u003eHowever, `lodash` and `clone` are kept to highlight important differences.\n\n\u003e **Note:** The `clone/include` candidate refers to its [`includeNonEnumerable` option](https://www.npmjs.com/package/clone#api) enabled.\n\n```\nLoad times:\n  lodash/clonedeep   29.257ms\n  rfdc                0.511ms\n  clone               0.576ms\n  clone-deep          2.494ms\n  deep-copy           0.451ms\n  klona/full          0.408ms\n  klona               0.265ms\n  klona/lite          0.308ms\n  klona/json          0.263ms\n\nBenchmark :: JSON\n  JSON.stringify      x   53,899 ops/sec ±0.76% (92 runs sampled)\n  lodash              x   46,800 ops/sec ±0.86% (90 runs sampled)\n  rfdc                x  221,456 ops/sec ±0.88% (92 runs sampled)\n  clone               x   39,537 ops/sec ±0.68% (92 runs sampled)\n  clone/include       x   25,488 ops/sec ±1.06% (88 runs sampled)\n  clone-deep          x   99,998 ops/sec ±0.91% (93 runs sampled)\n  deep-copy           x  141,270 ops/sec ±0.95% (92 runs sampled)\n  klona/full          x   55,016 ops/sec ±0.68% (94 runs sampled)\n  klona               x  281,215 ops/sec ±0.77% (93 runs sampled)\n  klona/lite          x  318,481 ops/sec ±0.72% (91 runs sampled)\n  klona/json          x  334,932 ops/sec ±0.66% (93 runs sampled)\n\nBenchmark :: LITE\n  lodash              x   36,992 ops/sec ±0.65% (91 runs sampled)\n  clone               x   35,974 ops/sec ±1.13% (88 runs sampled)\n  clone/include       x   22,609 ops/sec ±1.02% (91 runs sampled)\n  clone-deep          x   92,846 ops/sec ±0.66% (93 runs sampled)\n  klona/full          x   47,873 ops/sec ±0.83% (88 runs sampled)\n  klona               x  226,638 ops/sec ±1.16% (93 runs sampled)\n  klona/lite          x  257,900 ops/sec ±0.82% (93 runs sampled)\n\nBenchmark :: DEFAULT\n  lodash              x   55,914 ops/sec ±0.75% (93 runs sampled)\n    ✘ Buffer\n    ✘ Map keys\n  clone               x   92,127 ops/sec ±0.83% (94 runs sampled)\n    ✘ DataView\n  clone/include       x   62,052 ops/sec ±0.88% (93 runs sampled)\n    ✘ DataView\n  klona/full          x   90,308 ops/sec ±0.68% (89 runs sampled)\n  klona               x  230,257 ops/sec ±0.71% (91 runs sampled)\n\nBenchmark :: FULL\n  lodash              x   60,361 ops/sec ±0.65% (91 runs sampled)\n    ✘ Buffer\n    ✘ Map keys\n    ✘ Missing non-enumerable Properties\n  clone/include       x   47,263 ops/sec ±0.85% (93 runs sampled)\n    ✘ DataView\n    ✘ Incorrect non-enumerable Properties\n  klona/full          x   82,346 ops/sec ±0.62% (93 runs sampled)\n```\n\n\n## Related\n\n* [dlv](https://github.com/developit/dlv) – safely **read** from deep properties in 120 bytes\n* [dset](https://github.com/lukeed/dset) – safely **write** into deep properties in 160 bytes\n* [dequal](https://github.com/lukeed/dequal) – safely check for deep equality in 304 to 489 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%2Fklona","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flukeed%2Fklona","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flukeed%2Fklona/lists"}