• 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

    Parameters

    • from: unknown

      Any value to query.

    • path: string

      The query path.

    Returns Nullable<boolean>

  • 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

    Parameters

    • from: unknown

      Any value to query.

    • path: string

      The query path.

    • defaultValue: boolean

      The default to return if the query result was not defined.

    Returns boolean