@nevware21/ts-utils
    Preparing search index...

    Function objPick

    • Creates a new object composed of the picked enumerable own properties of source. Only keys present in the keys array are included in the returned object.

      Type Parameters

      • T

        The type of the source object

      • K extends string | number | symbol

        The key type (subset of keyof T)

      Parameters

      • source: T

        The source object to pick from

      • keys: ArrayLike<K>

        The array of keys to include

      Returns Pick<T, K>

      A new object containing only the specified keys and their values from source. Returns an empty object if source is null or undefined.

      0.14.0

      const obj = { a: 1, b: "hello", c: true };

      objPick(obj, ["a", "c"]); // { a: 1, c: true }
      objPick(obj, ["b"]); // { b: "hello" }
      objPick(obj, []); // {}
      objPick(null, ["a"]); // {}
    • Creates a new object composed of the picked enumerable own properties of source. Only keys present in the keys array are included in the returned object.

      Type Parameters

      • T

        The type of the source object

      Parameters

      • source: T

        The source object to pick from

      • keys: ArrayLike<string>

        The array of keys to include

      Returns Partial<T>

      A new object containing only the specified keys and their values from source. Returns an empty object if source is null or undefined.

      0.14.0

      const obj = { a: 1, b: "hello", c: true };

      objPick(obj, ["a", "c"]); // { a: 1, c: true }
      objPick(obj, ["b"]); // { b: "hello" }
      objPick(obj, []); // {}
      objPick(null, ["a"]); // {}
    • Creates a new object composed of the picked enumerable own properties of source. Only keys present in the keys array are included in the returned object.

      Type Parameters

      • T

        The type of the source object

      Parameters

      • source: T

        The source object to pick from

      • keys: ArrayLike<PropertyKey>

        The array of keys to include

      Returns Partial<T>

      A new object containing only the specified keys and their values from source. Returns an empty object if source is null or undefined.

      0.14.0

      const obj = { a: 1, b: "hello", c: true };

      objPick(obj, ["a", "c"]); // { a: 1, c: true }
      objPick(obj, ["b"]); // { b: "hello" }
      objPick(obj, []); // {}
      objPick(null, ["a"]); // {}