Extremely fast deep cloning function
npm install fast-clone




The fastest deep cloning function on NPM that supports the following types:
- Objects (POJOs, null, undefined)
- Arrays
- Dates
- Regular Expressions
- Strings
- Numbers (NaN, Positive Infinity, Negative Infinity)
- Booleans
Library | 7.15 MB |
-------------------|------------|
✔ fast-clone | 120 ms |
✘ deepClone | 138 ms |
✘ lodash.cloneDeep | 155 ms |
✘ snapshot | 1,127 ms |
✘ angular.copy | 1,942 ms |
✘ clone | 2,085 ms |
sh
npm install fast-clone --save
`$3
`sh
yarn add fast-clone
`Usage
Fast-clone is a UMD module so you can use it in Node.js, or in Browser either using Browserfy/Webpack, or by using the global clone function if not using a module loader.$3
`ts
import clone = require('fast-clone');
`$3
`js
const clone = require('fast-clone');
``ts
const a = {
name: 'Natasha Rominov',
age: 30,
skills: [
'Pistols',
'Espionage'
],
dateOfBirth: new Date('1986-05-21T00:00:00.000Z')
};const b = clone(a);
b.skills.push('That grabby thing she does with her legs');
console.log(a.skills)
console.log(b.skills);
`Output will be:
`ts
['Pistols', 'Espionage']
['Pistols', 'Espionage', 'That grabby thing she does with her legs']
``Pull-requests are also welcome. 😸