0.0.1 • Published 4 years ago

@util-funcs/object-set v0.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
4 years ago

object-set

Set deep property by key chaining and manipulate given object.

npm version Build Status

Getting Started

import set from '@util-funcs/object-set';

Installing

npm i @util-funcs/object-set --save

or

yarn add @util-funcs/object-set

Examples

let data = {};

data = set(data, 'a.b.c.d.e', 'test data');

// output:
{
  a: {
    b: {
      c: {
        d: {
          e: 'test data'
        }
      }
    }
  }
}

Object will be manipulate and return it same reference. You do not have to assign return data to a variable.

let data = {};

set(data, 'a.b.c.d.e', true);

// data:
{
  a: {
    b: {
      c: {
        d: {
          e: true
        }
      }
    }
  }
}

Run tests

npm test

Built With

Versioning

We use SemVer for versioning.

Authors

License

This project is licensed under the MIT License - see the LICENSE.md file for details