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

    Function includeKeys

    • Filter and include specific keys from an object (Based on https://github.com/sindresorhus/filter-obj)

      Type Parameters

      • O extends Record<PropertyKey, any>

        The object to filter and include keys from

      • K extends string | number | symbol

        The key type

      Parameters

      • object: O

        The object to filter and include keys from

      • keys: Iterable<K>

        The keys or keysCallback to include from the object

      Returns Pick<O, K>

      A new object with the included keys

      const object = {
      foo: true,
      bar: false
      };
      const newObject = includeKeys(object, (key, value, obj) => value === true); //=> {foo: true}
      const newObject = includeKeys(object, ['bar']); //=> {bar: false}

      v0.2.8

    • Filter and include specific keys from an object (Based on https://github.com/sindresorhus/filter-obj)

      Type Parameters

      • O extends Record<PropertyKey, any>

        The object to filter and include keys from

      • K extends string | number | symbol

        The key type

      Parameters

      • object: O

        The object to filter and include keys from

      • keyCallback: KeyCallback<O, K>

      Returns Partial<O>

      A new object with the included keys

      const object = {
      foo: true,
      bar: false
      };
      const newObject = includeKeys(object, (key, value, obj) => value === true); //=> {foo: true}
      const newObject = includeKeys(object, ['bar']); //=> {bar: false}

      v0.2.8