@vgerbot/async
    Preparing search index...

    Function pick

    • Creates an object composed of properties for which the predicate returns truthy. Similar to filter but returns an object instead of an array.

      Type Parameters

      • T

        The type of the object values.

      Parameters

      • obj: Record<string, T> | Promise<Record<string, T>>

        The object to iterate over.

      • predicate: (value: T, key: string, token: CancellableToken) => Promise<boolean>

        An async function that tests each property.

      • Optionaloptions: PickOptions<T>

        Configuration options, including concurrency limit.

      Returns CancellableHandle<Record<string, T>>

      A cancellable handle that resolves to an object with picked properties.

      const data = { a: 1, b: 2, c: 3, d: 4 };

      const handle = pick(
      data,
      async (value, key, token) => {
      await token.sleep(10);
      return value % 2 === 0;
      },
      );

      const result = await handle; // { b: 2, d: 4 }