import { AnyArray, AnyConstructor, AnyFunction, AnyJson, JsonArray, JsonMap, Nullable, Optional, Dictionary } from '../types'; /** * Given a deep-search query path, returns an object property or array value of an object or array. * * ``` * const obj = { foo: { bar: ['baz'] } }; * const value = get(obj, 'foo.bar[0]'); * // type of value -> unknown; value === 'baz' * * const value = get(obj, 'foo.bar.nothing', 'default'); * // type of value -> unknown; value === 'default' * * const value = get(obj, 'foo["bar"][0]'); * // type of value -> unknown; value === 'baz' * * const arr = [obj]; * const value = get(arr, '[0].foo.bar[0]'); * // type of value -> unknown; value === 'baz' * ``` * * @param from Any value to query. * @param path The query path. * @param defaultValue The default to return if the query result was not defined. */ export declare function get(from: unknown, path: string, defaultValue?: unknown): unknown; /** * Given a deep-search query path, returns an object property or array value of an object or array as a `string`, or * `undefined` if a value was not found or was not type-compatible. * * ``` * const obj = { foo: { bar: ['baz'] } }; * const value = getString(obj, 'foo.bar[0]'); * // type of value -> string; value -> 'baz' * ``` * * @param from Any value to query. * @param path The query path. */ export declare function getString(from: unknown, path: string): Nullable; /** * Given a deep-search query path, returns an object property or array value of an object or array as a `string`, or * `undefined` if a value was not found or was not type-compatible. * * ``` * const obj = { foo: { bar: ['baz'] } }; * const value = getString(obj, 'foo.bar[1]', 'default'); * // type of value -> string; value -> 'default' * ``` * * @param from Any value to query. * @param path The query path. * @param defaultValue The default to return if the query result was not defined. */ export declare function getString(from: unknown, path: string, defaultValue: string): string; /** * Given a deep-search query path, returns an object property or array value of an object or array as a `number`, or * `undefined` if a value was not found or was not type-compatible. * * ``` * const obj = { foo: { bar: [1] } }; * const value = getNumber(obj, 'foo.bar[0]'); * // type of value -> number; value -> 1 * ``` * * @param from Any value to query. * @param path The query path. */ export declare function getNumber(from: unknown, path: string): Nullable; /** * Given a deep-search query path, returns an object property or array value of an object or array as a `number`, or * `undefined` if a value was not found or was not type-compatible. * * ``` * const obj = { foo: { bar: [1] } }; * const value = getNumber(obj, 'foo.bar[1]', 2); * // type of value -> number; value -> 2 * ``` * * @param from Any value to query. * @param path The query path. * @param defaultValue The default to return if the query result was not defined. */ export declare function getNumber(from: unknown, path: string, defaultValue: number): number; /** * Given a deep-search query path, returns an object property or array value of an object or array as a `boolean`, or * `undefined` if a value was not found or was not type-compatible. * * ``` * const obj = { foo: { bar: [true] } }; * const value = getBoolean(obj, 'foo.bar[0]'); * // type of value -> boolean; value -> true * ``` * * @param from Any value to query. * @param path The query path. */ export declare function getBoolean(from: unknown, path: string): Nullable; /** * Given a deep-search query path, returns an object property or array value of an object or array as a `boolean`, or * `undefined` if a value was not found or was not type-compatible. * * ``` * const obj = { foo: { bar: [true] } }; * const value = getBoolean(obj, 'foo.bar[1]', false); * // type of value -> boolean; value -> false * ``` * * @param from Any value to query. * @param path The query path. * @param defaultValue The default to return if the query result was not defined. */ export declare function getBoolean(from: unknown, path: string, defaultValue: boolean): boolean; /** * Given a deep-search query path, returns an object property or array value of an object or array as an `object`, or * `undefined` if a value was not found or was not type-compatible. * * ``` * const obj = { foo: { bar: [{ name: 'baz' }] } }; * const value = getObject(obj, 'foo.bar[0]'); * // type of value -> object; value -> { name: 'baz' } * ``` * * @param from Any value to query. * @param path The query path. */ export declare function getObject(from: unknown, path: string): Nullable; /** * Given a deep-search query path, returns an object property or array value of an object or array as an `object`, or * `undefined` if a value was not found or was not type-compatible. * * ``` * const obj = { foo: { bar: [{ name: 'baz' }] } }; * const value = getObject(obj, 'foo.bar[1]', { name: 'buzz' }); * // type of value -> object; value -> { name: 'buzz' } * ``` * * @param from Any value to query. * @param path The query path. * @param defaultValue The default to return if the query result was not defined. */ export declare function getObject(from: unknown, path: string, defaultValue: T): T; /** * Given a deep-search query path, returns an object property or array value of an object or array as an `object`, or * `undefined` if a value was not found or was not type-compatible. This differs from {@link getObject} by way of * testing for the property value type compatibility using {@link isPlainObject} instead of {@link isObject}. * * ``` * const obj = { foo: { bar: [{ name: 'baz' }] } }; * const value = getPlainObject(obj, 'foo.bar[0]'); * // type of value -> object; value -> { name: 'baz' } * ``` * * @param from Any value to query. * @param path The query path. */ export declare function getPlainObject(from: unknown, path: string): Nullable; /** * Given a deep-search query path, returns an object property or array value of an object or array as an `object`, or * `undefined` if a value was not found or was not type-compatible. This differs from {@link getObject} by way of * testing for the property value type compatibility using {@link isPlainObject} instead of {@link isObject}. * * ``` * const obj = { foo: { bar: [{ name: 'baz' }] } }; * const value = getPlainObject(obj, 'foo.bar[1]', { name: 'buzz' }); * // type of value -> object; value -> { name: 'buzz' } * ``` * * @param from Any value to query. * @param path The query path. * @param defaultValue The default to return if the query result was not defined. */ export declare function getPlainObject(from: unknown, path: string, defaultValue: T): T; /** * Given a deep-search query path, returns an object property or array value of an object or array as a `Dictionary`, or * `undefined` if a value was not found or was not type-compatible. * * ``` * const obj = { foo: { bar: [{ name: 'baz' }] } }; * const value = getDictionary(obj, 'foo.bar[0]'); * // type of value -> Dictionary; value -> { name: 'baz' } * ``` * * @param from Any value to query. * @param path The query path. */ export declare function getDictionary(from: unknown, path: string): Nullable>; /** * Given a deep-search query path, returns an object property or array value of an object or array as an `Dictionary`, or * `undefined` if a value was not found or was not type-compatible. * * ``` * const obj = { foo: { bar: [{ name: 'baz' }] } }; * const value = getDictionary(obj, 'foo.bar[1]', { name: 'buzz' }); * // type of value -> Dictionary; value -> { name: 'buzz' } * ``` * * @param from Any value to query. * @param path The query path. * @param defaultValue The default to return if the query result was not defined. */ export declare function getDictionary(from: unknown, path: string, defaultValue: Dictionary): Dictionary; /** * Given a deep-search query path, returns an object property or array value of an object or array as an instance of * class type `C`, or `undefined` if a value was not found or was not type-compatible. * * ``` * class Example { ... } * const obj = { foo: { bar: [new Example()] } }; * const value = getInstance(obj, 'foo.bar[0]', Example); * // type of value -> Example * ``` * * @param from Any value to query. * @param path The query path. */ export declare function getInstance(from: unknown, path: string, ctor: C): Nullable>; /** * Given a deep-search query path, returns an object property or array value of an object or array as an instance of * class type `C`, or `undefined` if a value was not found or was not type-compatible. * * ``` * class Example { ... } * const obj = { foo: { bar: [new Example()] } }; * const value = getInstance(obj, 'foo.bar[0]', Example); * // type of value -> Example; value -> new Example() * ``` * * @param from Any value to query. * @param path The query path. * @param defaultValue The default to return if the query result was not defined. */ export declare function getInstance(from: unknown, path: string, ctor: C, defaultValue: InstanceType): InstanceType; /** * Given a deep-search query path, returns an object property or array value of an object or array as an * {@link AnyArray}, or `undefined` if a value was not found or was not type-compatible. * * ``` * const obj = { foo: { bar: [1, 2, 3] } }; * const value = getArray(obj, 'foo.bar'); * // type of value -> AnyArray; value -> [1, 2, 3] * ``` * * @param from Any value to query. * @param path The query path. */ export declare function getArray(from: unknown, path: string): Nullable; /** * Given a deep-search query path, returns an object property or array value of an object or array as an * {@link AnyArray}, or `undefined` if a value was not found or was not type-compatible. * * ``` * const obj = { foo: { bar: [1, 2, 3] } }; * const value = getArray(obj, 'foo.baz', [4, 5, 6]); * // type of value -> AnyArray; value -> [4, 5, 6] * ``` * * @param from Any value to query. * @param path The query path. * @param defaultValue The default to return if the query result was not defined. */ export declare function getArray(from: unknown, path: string, defaultValue: AnyArray): AnyArray; /** * Given a deep-search query path, returns an object property or array value of an object or array as an * {@link AnyFunction}, or `undefined` if a value was not found or was not type-compatible. * * ``` * const obj = { foo: { bar: [(arg: string) => `Hi, ${arg}`] } }; * const value = getFunction(obj, 'foo.bar[0]'); * // type of value -> AnyArray; value -> (arg: string) => `Hi, ${arg}` * ``` * * @param from Any value to query. * @param path The query path. */ export declare function getFunction(from: unknown, path: string): Nullable; /** * Given a deep-search query path, returns an object property or array value of an object or array as an * {@link AnyFunction}, or `undefined` if a value was not found or was not type-compatible. * * ``` * const obj = { foo: { bar: [(arg: string) => `Hi, ${arg}`] } }; * const value = getFunction(obj, 'foo.bar[1]', (arg: string) => `Bye, ${arg}`); * // type of value -> AnyArray; value -> (arg: string) => `Bye, ${arg}`) * ``` * * @param from Any value to query. * @param path The query path. * @param defaultValue The default to return if the query result was not defined. */ export declare function getFunction(from: unknown, path: string, defaultValue: AnyFunction): AnyFunction; /** * Given a deep-search query path, returns an object property or array value of a {@link JsonCollection} as an * {@link AnyJson}, or `undefined` if a value was not found or was not type-compatible. * * See {@link coerceAnyJson} for caveats regarding shallow type detection of `AnyJson` values from untyped sources. * * ``` * const obj = { foo: { bar: [{ a: 'b' }] } }; * const value = getAnyJson(obj, 'foo.bar[0]'); * // type of value -> AnyJson; value -> { a: 'b' } * ``` * * @param from The JSON value to query. * @param path The query path. */ export declare function getAnyJson(from: Optional, path: string): Optional; /** * Given a deep-search query path, returns an object property or array value of a {@link JsonCollection} as an * {@link AnyJson}, or the given default if a value was not found or was not type-compatible. * * ``` * const obj = { foo: { bar: [{ a: 'b' }] } }; * const value = getAnyJson(obj, 'foo.bar[1]', { c: 'd' }); * // type of value -> AnyJson; value -> { c: 'd' } * ``` * * @param from The JSON value to query. * @param path The query path. * @param defaultValue The default to return if the query result was not defined. */ export declare function getAnyJson(from: Optional, path: string, defaultValue: AnyJson): AnyJson; /** * Given a deep-search query path, returns an object property or array value from an {@link AnyJson} as a * {@link JsonMap}, or `undefined` if a value was not found or was not type-compatible. * * ``` * const obj = { foo: { bar: [{ a: 'b' }] } }; * const value = getJsonMap(obj, 'foo.bar[0]'); * // type of value -> JsonMap; value -> { a: 'b' } * ``` * * @param from The JSON value to query. * @param path The query path. */ export declare function getJsonMap(from: Optional, path: string): Nullable; /** * Given a deep-search query path, returns an object property or array value from an {@link AnyJson} as a * {@link JsonMap}, or the given default if a value was not found or was not type-compatible. * * ``` * const obj = { foo: { bar: [{ a: 'b' }] } }; * const value = getJsonMap(obj, 'foo.bar[1]', { c: 'd' }); * // type of value -> JsonMap; value -> { c: 'd' } * ``` * * @param from The JSON value to query. * @param path The query path. * @param defaultValue The default to return if the query result was not defined. */ export declare function getJsonMap(from: Optional, path: string, defaultValue: JsonMap): JsonMap; /** * Given a deep-search query path, returns an object property or array value from an {@link AnyJson} as a * {@link JsonArray}, or `undefined` if a value was not found or was not type-compatible. * * ``` * const obj = { foo: { bar: [1, 2, 3] } }; * const value = getJsonArray(obj, 'foo.bar'); * // type of value -> JsonArray; value -> [1, 2, 3] * ``` * * @param from The JSON value to query. * @param path The query path. */ export declare function getJsonArray(from: Optional, path: string): Nullable; /** * Given a deep-search query path, returns an object property or array value from an {@link AnyJson} as a * {@link JsonArray}, or the given default if a value was not found or was not type-compatible. * * ``` * const obj = { foo: { bar: [1, 2, 3] } }; * const value = getJsonArray(obj, 'foo.baz', [4, 5, 6]); * // type of value -> JsonArray; value -> [4, 5, 6] * ``` * * @param from The JSON value to query. * @param path The query path. * @param defaultValue The default to return if the query result was not defined. */ export declare function getJsonArray(from: Optional, path: string, defaultValue: JsonArray): JsonArray;