import { Deep } from "https://deno.land/x/rimbu@1.0.2/deep/index.ts";
const { getAt } = Deep;
Returns the value resulting from selecting the given path
in the given source
object.
It supports optional chaining for nullable values or values that may be undefined, and also
for accessing objects inside an array.
There is currently no support for forcing non-null (the !
operator).
Examples
Example 1
Example 1
const value = { a: { b: { c: [{ d: 5 }, { d: 6 }] } } }
Deep.getAt(value, 'a.b');
// => { c: 5 }
Deep.getAt(value, 'a.b.c');
// => [{ d: 5 }, { d: 5 }]
Deep.getAt(value, 'a.b.c[1]');
// => { d: 6 }
Deep.getAt(value, 'a.b.c[1]?.d');
// => 6