import { SafeUnknownObject } from "https://deno.land/x/dtils@2.3.1/mod.ts";
Gets the value of an object path in the object. If a key doesn't exist, a SafeUnknown
with null
will be returned. If a key gives null,
either by it not existing, or it actually being null, a SafeUnknown
with null
is immediately returned.
Examples:
new SafeUnknownObject({ foo: null }).get('foo', 'bar', 'bin', 'baz').isNull() // true
new SafeUnknownObject({}).get('foo').isNull() // true
new SafeUnknownObject({}).get('foo', 'bar', 'bin', 'baz').isNull() // true
new SafeUnknownObject({ foo: "hello" }).get('foo', 'bar', 'bin', 'baz') // Error: Expected data to be an object, but found type string at $.foo
new SafeUnknownObject({ foo: { bar: { bin: { baz: "Hello" }}}}).asString() // "Hello"