1.0.1 • Published 2 months ago

array-of-truths v1.0.1

Weekly downloads
-
License
ISC
Repository
github
Last release
2 months ago

array-of-truths

Ensure your input becomes an Array, and keep only the truthy values.

API

This module exports one function that holds another function:

arrayOfTruths(x)

If x is not an array, it will be treated as an array with x as the only item. Return a new Array that contains the truthy items from x.

.ifAny(x)

Like arrayOfTruths(x) but if there are no truthy items, instead of an empty array, return number 0.

.ifAnyMap(x, m)

Map a list x through one or more mapper functions m (function or array of functions), except initially and also after each step, false-y items are removed from the list. If the list would be empty, return number 0 instead.

Usage

see test/usage.mjs.

Known issues

  • I find the package name tricky to pronounce.

 

License

ISC

1.0.1

2 months ago

1.0.0

1 year ago

0.0.1

1 year ago