ts-data-forge
    Preparing search index...

    Function deepPick

    • Deeply picks a nested property from an object along the specified key path. Supports both direct and curried usage.

      Type Parameters

      • const R extends UnknownRecord

        The type of the input record

      • const Path extends readonly (string | number)[]

        The key path tuple

      Parameters

      • record: R

        The source record

      • path: Path

        A readonly tuple of keys representing the nested path

      Returns DeepPick<R, Path>

      A new record containing only the nested property at the path

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

      // Direct usage
      const result = Obj.deepPick(data, ['a', 'b', 'c']);
      assert.deepStrictEqual(result, { a: { b: { c: 1 } } });

      // Curried usage with pipe
      const pickName = Obj.deepPick(['user', 'name']);
      const result2 = pipe(data).map(pickName).value;
    • Deeply picks a nested property from an object along the specified key path. Supports both direct and curried usage.

      Type Parameters

      • const Path extends readonly (string | number)[]

        The key path tuple

      Parameters

      • path: Path

        A readonly tuple of keys representing the nested path

      Returns <const R extends UnknownRecord>(record: R) => DeepPick<R, Path>

      A new record containing only the nested property at the path

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

      // Direct usage
      const result = Obj.deepPick(data, ['a', 'b', 'c']);
      assert.deepStrictEqual(result, { a: { b: { c: 1 } } });

      // Curried usage with pipe
      const pickName = Obj.deepPick(['user', 'name']);
      const result2 = pipe(data).map(pickName).value;