https://github.com/raineorshine/fp-and-or
Simple `and` and `or` functional programming predicates
https://github.com/raineorshine/fp-and-or
fp
Last synced: 7 months ago
JSON representation
Simple `and` and `or` functional programming predicates
- Host: GitHub
- URL: https://github.com/raineorshine/fp-and-or
- Owner: raineorshine
- License: isc
- Created: 2020-11-11T22:21:57.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2023-11-05T03:22:08.000Z (almost 2 years ago)
- Last Synced: 2025-03-18T07:51:48.318Z (7 months ago)
- Topics: fp
- Language: JavaScript
- Homepage:
- Size: 712 KB
- Stars: 5
- Watchers: 2
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README-template.md
- License: LICENSE
Awesome Lists containing this project
README
# fp-and-or
[](https://npmjs.org/package/fp-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 isEven = n => n%2 === 0
const isPositive = n => n > 0// un-fancy
items.filter(x => isEven(x) || isPositive(x))// fancy
items.filter(or(isEven, isPositive))
```## Install
```sh
npm install --save fp-and-or
```## Usage
```js
const { and, or } = require('fp-and-or')<%=usage%>