pickWithRest
Commons
stable
Split an object's keys into two buckets: `yes` (keys matching any of the paths, minus any explicitly excluded ones) and `no` (everything else). Paths may be plain strings or `RegExp` patterns.
API
Signature
Full TypeScript signature sourced from the util file.
API
Parameters
Input parameters accepted by this util.
- objrequiredT
- The source object to split.
- pathsrequiredArray<(U | RegExp)>
- An array of string keys and/or regular expressions. A key is placed in the `yes` bucket when it matches any entry in this array.
- excludeArray<E>
- Optional array of keys to forcibly keep in the `no` bucket even when they match a path or regex.
API
Return value
The value returned by this util.
- A 2-tuple: the first element contains matched keys, the second contains all remaining keys. Neither input is mutated.
Usage
Examples
Ready-to-paste usage snippets.
Split component props from inherited attrs