lens-o 
- Parse object path
- Get value from parsed path
- Set value to parsed path
Install
npm install lens-o
Usage
import { parse, get, set } from 'lens-o';
const path = parse('a.b.1.c');
const path = parse.ignore('a.b.-1.c');
const path = parse.unsafe('a.b.-1.c');
const path = parse.abs('a.b.-1.c');
const val = get('a.b.1.c', {
a: {
b: [
{
c: 'hello',
},
{
c: 'world',
},
],
},
});
const val = get(path, {
a: {
b: [
{
c: 'hello',
},
{
c: 'world',
},
],
},
});
const val = set('a.b.1.c', 'x', {
a: {
b: [
{
c: 'hello',
},
{
c: 'world',
},
],
},
});
const val = set(path, 'x', {
a: {
b: [
{
c: 'hello',
},
{
c: 'world',
},
],
},
});
License
MIT