nanofilters
v2.1.1
Published
simple array filters for es6
Downloads
8
Readme
Nano Filters
Tiny (<3Kb) array filters lib with both ESM and CJS support:
const arr = [1, "2", { arg: 3 }, [4], null, undefined];
truthy(arr); // excludes false, 0, null, undefined, ''
head(arr, 1); // gets N head elements
tail(arr, 2); // gets N tail elements
objects(arr); // selects objects
objects.plain(arr); // selects only plain objects (null proto or Object.prototype)
vals(arr); // excludes null and undefined
instances(arr, C); // selects only instances of C
bools(arr); // selects only true, false and instances of Boolean
nums(arr); // selects numbers excluding Infinites and NaN
strings(arr); // selects strings only
// Some functions have 'not' postfix buddy:
truthy.not(arr); // excludes truthy
nums.not(arr); // excludes numbers
// etc...
https://www.npmjs.com/package/nanofilters