Find derived
Like Array.prototype.find
but returns the result of the first derived values (ie. function call on an item in the list) that is truthy.
Usage
const derive = item > 2 ? item * 2 : false// 6return
Add to Array prototype
// 6return 1234
Strategy pattern
A common usage is to use this to try different strategies. Each strategy can have a guard
strategies = tryLocalCache tryDownloadRepo tryDownloadNpm { // guard clause if ! return false // resolve from cache // ... return files} // retrieve files of first strategy that resolvesconst files = strategies
License
MIT