{"author":{"name":"tony_quetano@planttheidea.com"},"contributors":[{"name":"Dariusz Rzepka","email":"rzepkadarek@gmail.com"}],"browser":"dist/umd/index.js","bugs":{"url":"https://github.com/planttheidea/fast-copy/issues"},"description":"A blazing fast deep object copier","devDependencies":{"@rollup/plugin-node-resolve":"^14.1.0","@rollup/plugin-typescript":"^8.5.0","@types/eslint":"^8.4.6","@types/jest":"^29.0.3","@types/lodash":"^4.14.185","@types/node":"^18.7.18","@types/ramda":"^0.28.15","@types/react":"^18.0.20","@typescript-eslint/eslint-plugin":"^5.38.0","@typescript-eslint/parser":"^5.38.0","benchee":"^1.0.3","cli-table3":"^0.6.3","clone":"^2.1.2","deepclone":"^1.0.2","eslint":"^8.23.1","eslint-webpack-plugin":"^3.2.0","fast-clone":"^1.5.3","html-webpack-plugin":"^5.5.0","in-publish":"^2.0.1","jest":"^29.0.3","lodash":"^4.17.11","nyc":"^15.1.0","ramda":"^0.28.0","react":"^18.2.0","react-dom":"^18.2.0","release-it":"15.4.1","rollup":"^2.79.1","rollup-plugin-terser":"^7.0.2","ts-jest":"^29.0.1","ts-loader":"^9.4.1","typescript":"^4.8.3","webpack":"^5.74.0","webpack-cli":"^4.10.0","webpack-dev-server":"^4.11.1"},"exports":{".":{"import":{"types":"./dist/esm/types/index.d.ts","default":"./dist/esm/index.mjs"},"require":{"types":"./dist/cjs/types/index.d.ts","default":"./dist/cjs/index.cjs"},"default":{"types":"./dist/umd/types/index.d.ts","default":"./dist/umd/index.js"}}},"homepage":"https://github.com/planttheidea/fast-copy#readme","keywords":["clone","deep","copy","fast"],"license":"MIT","main":"dist/cjs/index.cjs","module":"dist/esm/index.mjs","name":"fast-copy","repository":{"type":"git","url":"git+https://github.com/planttheidea/fast-copy.git"},"scripts":{"benchmark":"npm run build:files && node benchmark/index.cjs","build":"npm run build:files && npm run build:types","build:files":"NODE_ENV=production rollup -c","build:types":"tsc -p ./tsconfig.cjs.json && tsc -p ./tsconfig.esm.json && tsc -p ./tsconfig.umd.json && tsc -p ./tsconfig.minified.json","clean":"rimraf dist","dev":"NODE_ENV=development webpack-dev-server --config=webpack/webpack.config.js","dist":"npm run clean && npm run build","lint":"eslint 'src/*.ts'","lint:fix":"npm run lint -- --fix","prepublishOnly":"npm run lint && npm run typecheck && npm run test && npm run dist","release":"release-it","release:beta":"release-it --config=.release-it.beta.json","release:dry":"release-it --dry-run","start":"npm run dev","test":"NODE_PATH=. jest","test:coverage":"npm run test -- --coverage","test:watch":"npm run test -- --watch","typecheck":"tsc src/*.ts --noEmit"},"type":"module","types":"index.d.ts","version":"3.0.0-beta.5","readme":"# fast-copy\n\n<img src=\"https://img.shields.io/badge/build-passing-brightgreen.svg\"/>\n<img src=\"https://img.shields.io/badge/coverage-100%25-brightgreen.svg\"/>\n<img src=\"https://img.shields.io/badge/license-MIT-blue.svg\"/>\n\nA [blazing fast](#benchmarks) deep object copier\n\n## Table of contents\n\n- [fast-copy](#fast-copy)\n  - [Table of contents](#table-of-contents)\n  - [Usage](#usage)\n  - [API](#api)\n    - [`copy`](#copy)\n    - [`copyStrict`](#copystrict)\n    - [`createCopier`](#createcopier)\n  - [Types supported](#types-supported)\n  - [Aspects of copying](#aspects-of-copying)\n    - [Error references are copied over (instead of creating a new `*Error` object)](#error-references-are-copied-over-instead-of-creating-a-new-error-object)\n    - [The constructor of the original object is used, instead of using known globals.](#the-constructor-of-the-original-object-is-used-instead-of-using-known-globals)\n  - [Benchmarks](#benchmarks)\n      - [Simple objects](#simple-objects)\n      - [Complex objects](#complex-objects)\n      - [Big data](#big-data)\n      - [Circular objects](#circular-objects)\n      - [Special objects](#special-objects)\n  - [Development](#development)\n\n## Usage\n\n```javascript\nimport { copy } from 'fast-copy';\nimport { deepEqual } from 'fast-equals';\n\nconst object = {\n  array: [123, { deep: 'value' }],\n  map: new Map([\n    ['foo', {}],\n    [{ bar: 'baz' }, 'quz'],\n  ]),\n};\n\nconst copiedObject = copy(object);\n\nconsole.log(copiedObject === object); // false\nconsole.log(deepEqual(copiedObject, object)); // true\n```\n\n## API\n\n### `copy`\n\nDeeply copy the object passed.\n\n```ts\nimport copy from 'fast-copy';\n\nconst copied = copy({ foo: 'bar' });\n```\n\n### `copyStrict`\n\nDeeply copy the object passed, but with additional strictness when replicating the original object:\n\n- Properties retain their original property descriptor\n- Non-enumerable keys are copied\n- Non-standard properties (e.g., keys on an `Array` object) are copied\n\n```ts\nimport { copyStrict } from 'fast-copy';\n\nconst object = { foo: 'bar' };\nobject.nonEnumerable = Object.defineProperty(object, 'bar', {\n  enumerable: false,\n  value: 'baz',\n});\n\nconst copied = copy(object);\n```\n\n**NOTE**: This method is significantly slower than [`copy`](#copy), so it is recommended to only use this when you have specific use-cases that require it.\n\n### `createCopier`\n\nCreate a custom copier based on the object-specific methods passed. This is useful if you want to squeeze out maximum performance.\n\n```ts\nimport { createCopier } from 'fast-copy';\n\nconst shallowCloneArray = (array) => [...array];\nconst shallowCloneMap = (map) => new Map(map.entries());\nconst shallowCloneObject = (object) => { ...object };\nconst shallowCloneSet = (set) => new Set(set.values());\n\nconst copyShallow = createCopier({\n  array: shallowCloneArray,\n  map: shallowCloneMap,\n  object: shallowCloneObject,\n  set: shallowCloneSet,\n});\n```\n\n## Types supported\n\nThe following object types are deeply cloned when they are either properties on the object passed, or the object itself:\n\n- `Array`\n- `ArrayBuffer`\n- `Blob`\n- `Buffer`\n- `DataView`\n- `Date`\n- `Float32Array`\n- `Float64Array`\n- `Int8Array`\n- `Int16Array`\n- `Int32Array`\n- `Map`\n- `Object`\n- `RegExp`\n- `Set`\n- `Uint8Array`\n- `Uint8ClampedArray`\n- `Uint16Array`\n- `Uint32Array`\n- `React` components\n- Custom constructors\n\nThe following object types are copied directly, as they are either primitives, cannot be cloned, or the common use-case implementation does not expect cloning:\n\n- `AsyncFunction`\n- `Boolean`\n- `Error`\n- `Function`\n- `GeneratorFunction`\n- `Number`\n- `Null`\n- `Promise`\n- `String`\n- `Symbol`\n- `Undefined`\n- `WeakMap`\n- `WeakSet`\n\nCircular objects are supported out of the box. By default, a cache based on `WeakSet` is used, but if `WeakSet` is not available then a fallback is used. The benchmarks quoted below are based on use of `WeakSet`.\n\n## Aspects of copying\n\nInherently, what is considered a valid copy is subjective because of different requirements and use-cases. For this library, some decisions were explicitly made.\n\n### Error references are copied over (instead of creating a new `*Error` object)\n\nWhile it would be relatively trivial to copy over the message and stack to a new object of the same `Error` subclass, it is a common practice to \"override\" the message or stack, and copies would not retain this mutation. As such, the original reference is copied.\n\n### The constructor of the original object is used, instead of using known globals.\n\nStarting in ES2015, native globals can be subclassed like any custom class. When copying, we explicitly reuse the constructor of the original object. However, the expectation is that these subclasses would have the same constructur signature as their native base class. This is a common community practice, however because there is the possibility of inaccuracy if the contract differs, it should be noted.\n\n## Benchmarks\n\n#### Simple objects\n\n_Small number of properties, all values are primitives_\n\n|                    | Operations / second |\n| ------------------ | ------------------- |\n| **fast-copy**      | **2,692,822**       |\n| clone              | 1,420,277           |\n| lodash.cloneDeep   | 1,277,213           |\n| fast-deepclone     | 768,982             |\n| ramda              | 719,948             |\n| fast-clone         | 567,342             |\n| deepclone          | 509,547             |\n| fast-copy (strict) | 420,804             |\n\n#### Complex objects\n\n_Large number of properties, values are a combination of primitives and complex objects_\n\n|                    | Operations / second |\n| ------------------ | ------------------- |\n| **fast-copy**      | **109,352**         |\n| fast-deepclone     | 101,808             |\n| ramda              | 93,103              |\n| deepclone          | 74,270              |\n| fast-clone         | 49,911              |\n| clone              | 46,355              |\n| lodash.cloneDeep   | 43,900              |\n| fast-copy (strict) | 33,440              |\n\n#### Big data\n\n_Very large number of properties with high amount of nesting, mainly objects and arrays_\n\n|                    | Operations / second |\n| ------------------ | ------------------- |\n| **fast-copy**      | 123                 |\n| fast-deepclone     | 101                 |\n| fast-clone         | 93                  |\n| lodash.cloneDeep   | 92                  |\n| deepclone          | 66                  |\n| clone              | 50                  |\n| fast-copy (strict) | 42                  |\n| ramda              | 5                   |\n\n#### Circular objects\n\n_Objects that deeply reference themselves_\n\n|                            | Operations / second |\n| -------------------------- | ------------------- |\n| **fast-copy**              | **1,143,074**       |\n| ramda                      | 750,430             |\n| clone                      | 722,632             |\n| lodash.cloneDeep           | 580,005             |\n| deepclone                  | 490,824             |\n| fast-deepclone             | 446,585             |\n| fast-copy (strict)         | 321,678             |\n| fast-clone (not supported) | 0                   |\n\n#### Special objects\n\n_Custom constructors, React components, etc_\n\n|                    | Operations / second |\n| ------------------ | ------------------- |\n| **fast-copy**      | **78,422**          |\n| clone              | 52,165              |\n| lodash.cloneDeep   | 39,648              |\n| ramda              | 32,372              |\n| fast-deepclone     | 27,518              |\n| fast-clone         | 27,495              |\n| deepclone          | 16,552              |\n| fast-copy (strict) | 12,509              |\n\n## Development\n\nStandard practice, clone the repo and `yarn` (or `npm i`) to get the dependencies. The following npm scripts are available:\n\n- benchmark => run benchmark tests against other equality libraries\n- build => run `build:files` and `build:types`\n- build:files => build dist files with `rollup`\n- build:types => build TypeScript types for consumers\n- clean => run `rimraf` on the `dist` folder\n- dev => start webpack playground App\n- dist => run `build` and `build:minified` scripts\n- lint => run ESLint on all files in `src` folder (also runs on `dev` script)\n- lint:fix => run `lint` script, but with auto-fixer\n- prepublishOnly => run `lint`, `test:coverage`, and `dist` scripts\n- release => run `prepublishOnly` and release with new version\n- release:beta => run `prepublishOnly` and release with new beta version\n- release:dry => run `prepublishOnly` and simulate a new release\n- start => run `dev`\n- test => run AVA with NODE_ENV=test on all files in `test` folder\n- test:coverage => run same script as `test` with code coverage calculation via `nyc`\n- test:watch => run same script as `test` but keep persistent watcher\n","readmeFilename":"README.md","gitHead":"79fdbb17aae43132f14e4ce0cb4323b72895e57a","_id":"fast-copy@3.0.0-beta.5","_nodeVersion":"16.14.2","_npmVersion":"8.7.0","dist":{"integrity":"sha512-yv2hHhs3izFFO5jhxdKt0TSWpkwmmZnxUqXOURrfJyztMp+5HW/WExZtVJgm91jHxM85qlQeaGB4D+tamE+hzA==","shasum":"4fb44806650680ec1cfd2e97a65a7f1652b3e227","tarball":"http://registry-npm.ywwl.com/fast-copy/download/fast-copy-3.0.0-beta.5.tgz","fileCount":33,"unpackedSize":151710,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIEmwzy1inb93ME1TxyYLQrkWg6riB+OjzkUymQo77MTQAiEA0vQLMMLMCqQlL7tlRX8l1DmAdh9ykDFV0Q0NN+QGgsg="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjNXWrACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmpGwQ//XLwDTWNyElHnV8Njl+8F/XtREfJuWRK8Hu+Smeg/H+yIPp3h\r\n6g6M1bEr6h4mrr4l/jsiEPNUsPY3z5czsHeDuuN9sjB8OiUt/OFXrKKLR32F\r\nCLBokOZErw2Cxlt8+gs0lzICQ23oWJWVZqvUol4nFLlYymVhoIx9QGGzXbzA\r\no7aJajeeIzXkq70NR1lMBaS0vnjeqOzZ0uNqVYilrUt5LkVFHcQpXxat1+IN\r\nyZz1gF2GxhCDxAl5n1esY5bbbDEWRSK9Up3N1GsHwTcDZCuoYk4BtLEiZWMj\r\nkjEm7zuoD+cCzms9yoXK/LlQTF/uosjn3P5H31tTFw8uRrpoofyGsYRrOGGP\r\nYN5ahNQUSMetwXCQPEGgzA9iNVcyrQnsmiw+YA0y5UARVJcHvvOh/a06Dg16\r\nmOb3a+0MOS7MST7wEmF/iQKYmp6/ew8TTXS3wczwBSO4IE1WVzq5lMHzfBWj\r\n9iCsKdhmr5tZksHxXK/d+7zvGr4zFXq7pozNExKDQLeT9/EBkAvIDF+TL+Ai\r\nsFVH3ux/583uofotulH8202lnjgJEttYYFdPZbVaWH0eRhNa0YkxAX26meS9\r\nolJzWQN5Z6w7YbamMrb8VpP7SJ0UaySQacYsqUycI0/5VGAvObx2UAu9EuL3\r\n+PcpbZkPMym+B/L1zX7LU6MtU7q7Hc/8oXo=\r\n=RAaK\r\n-----END PGP SIGNATURE-----\r\n","size":24979,"noattachment":false,"key":"/fast-copy/-/fast-copy-3.0.0-beta.5.tgz"},"_npmUser":{"name":"planttheidea","email":"tony.quetano@planttheidea.com"},"directories":{},"maintainers":[{"name":"planttheidea","email":"tony.quetano@planttheidea.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/fast-copy_3.0.0-beta.5_1664447915357_0.222851669422373"},"_hasShrinkwrap":false,"publish_time":1664447915518,"_cnpm_publish_time":1664447915518,"dist-tags":{"latest":"4.3.1","latest-v2":"2.2.0","latest-v3":"3.1.0"}}