Util.paths Module
import { paths } from 'util';Methods
to(object, path, value, returnSourceObject)
import { paths } from 'util';
const object = {
foo: [
0,
1,
{two: 'two'}
]
};
paths.to(object, 'not.a.property'); // undefined
paths.to(object, 'foo.2.two'); // 'two'
paths.to({}, 'a.b.c', 'd'); // {c: 'd'}
paths.to({}, 'a.b.c', 'd', true); // {a: {b: {c: 'd'}}}Last updated
Was this helpful?