Nutty Penguin Music

    segmented-property

    3.0.3 • Public • Published

    segmented-property

    A utility for immutably setting and getting properties on JavaScript objects as slash-delimited paths.

    npm install segmented-property

    npm version

    Usage

    import {get, set} from 'segmented-property'
    
    const obj1 = {foo: {bar: 1}}
    const obj2 = set(obj1, 'foo/bar', 2)
    
    console.log(get(obj1, 'foo/bar')) // 1
    console.log(get(obj2, 'foo/bar')) // 2

    API

    get(source, [key])

    Gets a value.

    set(source, [key], value)

    Sets a new value and returns a new object.

    Keywords

    none

    Install

    npm i segmented-property

    DownloadsWeekly Downloads

    1,003

    Version

    3.0.3

    License

    MIT

    Unpacked Size

    13.3 kB

    Total Files

    20

    Last publish

    Collaborators

    • mariuslundgard