@unction/compact
v4.8.0
Published
Takes a collection (Array or Object) and returns a copy of that value without `null` or `undefined` values
Downloads
43
Readme
@unction/compact
ListType<A | null> | RecordType<unknown, A | null> => Array | Set | Record<string | number | symbol, B> | Map<B, A> | string
Takes a collection (Array or Object) and returns a copy of that value without null
or undefined
values.
avatarUrls // => [null, "/1.jpg", null, "/3.jpg"]
compact(avatarUrls) // => ["/1.jpg", "/3.jpg"]
user // {"avatar": null, "name": "Kurtis Rainbolt-Greene"}
compact(head(user)) // {"name": "Kurtis Rainbolt-Greene"}