@patomation/clone-deep
v0.0.1
Published
Recursive deep clone algorithm for object and arrays
Downloads
4
Maintainers
Readme
Clone Deep
Another deep clone algorithm for object and arrays
Install
npm i @patomation/clone-deep
Usage
import {cloneDeep} from '@patomation/clone-deep'
const objA = {foo: 'bar'}
const objB = cloneDeep(objA)
const objB.foo = 'baz'
// Result
objA.foo
// 'bar'
objA.foo
// 'baz'
// NOTE objA will not be changed when making mutations to objB
TypeScript usage
This module supports generic types
interface MyObject = {
foo: string
bar: string
}
const myObject: MyObject = {foo: 'biz', bar: 'buz'}
const myClonedObject = cloneDeep<MyObject>(myObject)
Test
npm run test
supports naming convention: moduleName.test.ts Check out ava