Novelty Polygonal Mathematics

    @patomation/clone-deep
    TypeScript icon, indicating that this package has built-in type declarations

    0.0.1 • Public • Published

    Clone Deep

    Another deep clone algorithm for object and arrays

    flavorite

    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

    Install

    npm i @patomation/clone-deep

    DownloadsWeekly Downloads

    5

    Version

    0.0.1

    License

    MIT

    Unpacked Size

    10 kB

    Total Files

    8

    Last publish

    Collaborators

    • patomation