@salesforce/ts-types
    Preparing search index...

    Function getDictionary

    • Given a deep-search query path, returns an object property or array value of an object or array as a Dictionary<T>, or undefined if a value was not found or was not type-compatible.

      const obj = { foo: { bar: [{ name: 'baz' }] } };
      const value = getDictionary<string>(obj, 'foo.bar[0]');
      // type of value -> Dictionary<string>; value -> { name: 'baz' }

      Type Parameters

      • T = unknown

      Parameters

      • from: unknown

        Any value to query.

      • path: string

        The query path.

      Returns Nullable<Dictionary<T>>

    • Given a deep-search query path, returns an object property or array value of an object or array as an Dictionary<T>, or undefined if a value was not found or was not type-compatible.

      const obj = { foo: { bar: [{ name: 'baz' }] } };
      const value = getDictionary<string>(obj, 'foo.bar[1]', { name: 'buzz' });
      // type of value -> Dictionary<string>; value -> { name: 'buzz' }

      Type Parameters

      • T = unknown

      Parameters

      • from: unknown

        Any value to query.

      • path: string

        The query path.

      • defaultValue: Dictionary<T>

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

      Returns Dictionary<T>