JSPM

pick-omit

2.0.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 163
  • Score
    100M100P100Q105635F
  • License MIT

The two missing object methods we always need.

Package Exports

  • pick-omit

Readme

pick-omit

The two missing object methods we always need.

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

API

# ObjectFilterFn src/pick-omit.ts#L3

    # (entry)

      # entry

        [ string, unknown ]

      (entry)  =>

        boolean

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

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

    filter<T>(obj, fn)  =>

      Partial<T>

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

    # obj – Object to filter.

    nonNull<T>(obj)  =>

      Pick<T, keyof NonNull<T>>

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

    # obj – Object to omit from.
    # props – Properties to omit.

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

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

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

    # obj – Object to pick from.
    # props – Properties to pick.

    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