@luolapeikko/ts-common
    Preparing search index...

    Function prop

    • Creates a function that selects a specific property value from an object.

      Useful for use with arrays map function when extracting a single property from each object.

      Type Parameters

      • T extends any[] | Record<PropertyKey, any>

        Object target from which the property will be selected

      • K extends string | number | symbol

        Property name in target that will be selected

      Parameters

      • key: K

        The property name to select

      Returns (target: T) => T[K]

      select value by key from the target

      type Data = {demo: string, value: number|null};
      const dataArray: Data[] = [{demo: 'hello', value: null}];
      const output: string[] = dataArray.map(pick(['demo']));

      v0.4.2

    • Creates a function that selects a specific property value from an object.

      Useful for use with arrays map function when extracting a single property from each object.

      Type Parameters

      • K extends PropertyKey

        Property name in target that will be selected

      Parameters

      • key: K

        The property name to select

      Returns <T extends Record<K, any>>(target: T) => T[K]

      select value by key from the target

      type Data = {demo: string, value: number|null};
      const dataArray: Data[] = [{demo: 'hello', value: null}];
      const output: string[] = dataArray.map(pick(['demo']));

      v0.4.2