Have ideas to improve npm?Join in the discussion! »

    This package has been deprecated

    Author message:

    Package no longer supported. Please use lodash.set (https://lodash.com/docs/4.17.15#set)

    deep-set

    1.0.1 • Public • Published

    deep-set

    testling badge Build Status

    Sets a value of a property in an object tree. Missing objects will (optionally) be created.

    Installation

    npm install deep-set
    

    In the browser you can use deepSet with Browserify, RequireJS or as a window global.

    Usage

    var deepSet = require('deep-set')
    var obj = { one: { two: { three: 'sad' } } }
     
    deepSet(obj, 'one.two.three', 'yay')
    // { one: { two: { three: 'yay' } } }

    Arguments

    deepSet(obj, path, value, create)

    • obj - Object: The original object.
    • path - String: The path to traverse, separated by dots.
    • value - *: The value to set.
    • create - Boolean: Whether to create missing objects along the way default: true.

    Tests

    npm test
    

    License

    MIT

    Install

    npm i deep-set

    DownloadsWeekly Downloads

    145

    Version

    1.0.1

    License

    MIT

    Last publish

    Collaborators

    • avatar