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

Signature TypeScript complète, extraite du fichier util.

typescript

API

Paramètres

Paramètres d'entrée acceptés par cet util.

obj
requis
T
The source object to split.
paths
requis
Array<(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.
exclude
Array<E>
Optional array of keys to forcibly keep in the `no` bucket even when they match a path or regex.

API

Valeur de retour

La valeur retournée par cet util.

A 2-tuple: the first element contains matched keys, the second contains all remaining keys. Neither input is mutated.

Usage

Exemples

Extraits de code prêts à coller.

Split component props from inherited attrs

typescript