Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

pick-omit

stagas462MIT2.0.1TypeScript support: included

The two missing object methods we always need.

pick, omit, object, properties

readme

pick-omit

The two missing object methods we always need.

npm i pick-omit pnpm add pick-omit yarn add pick-omit

API

<summary># ObjectFilterFn </summary> src/pick-omit.ts#L3

    <summary># (entry) </summary>

      <summary># entry </summary>

        [ string, unknown ]

      (entry)  =>

        boolean

<summary># filter(obj, fn) – Filter object with filter function fn.</summary> src/pick-omit.ts#L12

    <summary># obj – Object to filter.</summary>
    <summary># fn – Filter function receiving [key, value].</summary>

    filter<T>(obj, fn)  =>

      Partial<T>

<summary># nonNull(obj) – Filter out nullish values from object.</summary> src/pick-omit.ts#L23

    <summary># obj – Object to filter.</summary>

    nonNull<T>(obj)  =>

      Pick<T, keyof NonNull<T>>

<summary># omit(obj, props) – Create a new object with certain properties omitted.</summary> src/pick-omit.ts#L46

    <summary># obj – Object to omit from.</summary>
    <summary># props – Properties to omit.</summary>

    omit<T, K>(obj, props)  =>

      Omit<T, K extends readonly U [] ? U : never>

<summary># pick(obj, props) – Pick properties from an object into a new object.</summary> src/pick-omit.ts#L33

    <summary># obj – Object to pick from.</summary>
    <summary># props – Properties to pick.</summary>

    pick<T, K>(obj, props)  =>

      Pick<T, K extends readonly U [] ? U : never>

Credits

Contributing

Fork or edit and submit a PR.

All contributions are welcome!

License

MIT © 2022 stagas