@util-funcs/object-set
TypeScript icon, indicating that this package has built-in type declarations

0.0.1 • Public • Published

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

Package Sidebar

Install

npm i @util-funcs/object-set

Weekly Downloads

1

Version

0.0.1

License

MIT

Unpacked Size

4.47 kB

Total Files

6

Last publish

Collaborators