get-set-object

1.0.0 • Public • Published

Get set library

This library is for adding or getting some properties from object by path in string

const { set } = reqyire('get-set-object');
const a = {};
set(a, 'users[0].name.firstName', 'John');
JSON.stringify(a); //{"users":[{"name":{"firstName":"John"}}]}
const { get } = reqyire('get-set-object');
const a = {
  users: [
    {
      name: {
        firstName: 'John',
        lastName: 'Smith',
      }
    }
  ]
}
get(a, 'users[0].name.lastName'); // Smith
const { deepClone } = reqyire('get-set-object');
const a = {
  users: [
    {
      name: {
        firstName: 'John',
        lastName: 'Smith',
      }
    }
  ]
}
const b = deepClone(a);

b.users[0] === a.users[0]; // false

Readme

Keywords

none

Package Sidebar

Install

npm i get-set-object

Weekly Downloads

2

Version

1.0.0

License

ISC

Unpacked Size

2.18 kB

Total Files

3

Last publish

Collaborators

  • dmitry.sam