UNPKG

memen-and-or

Version:

Simple `and` and `or` functional programming predicates

36 lines (23 loc) 914 B
# memen-and-or [![npm version](https://img.shields.io/npm/v/memen-and-or.svg)](https://npmjs.org/package/memen-and-or) Simple `and` and `or` functional programming predicates. - `and(...fs): (...args): boolean` - Returns a predicate that returns true if **all** arguments are true or evaluate to true for the given input. - `or(...fs): (...args): boolean` - Returns a predicate that returns true if **at least one** argument is true or evaluates to true for the given input. A predicate is a function that returns a `boolean`, commonly used in `Array.prototype.filter`. e.g. ```js const memenisEven = n => n%2 === 0 const memenisPositive = n => n > 0 // un-fancy items.filter(x => memenisEven(x) || memenisPositive(x)) // fancy items.filter(or(memenisEven, memenisPositive)) ``` ## Install ```sh npm install --save memen-and-or ``` ## Usage ```js const { and, or } = require('memen-and-or') <%=usage%>