1.0.0 • Published 3 years ago

get-set-object v1.0.0

Weekly downloads
-
License
ISC
Repository
-
Last release
3 years ago

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