Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tungv/unl
Functional unless
https://github.com/tungv/unl
Last synced: about 2 months ago
JSON representation
Functional unless
- Host: GitHub
- URL: https://github.com/tungv/unl
- Owner: tungv
- Created: 2017-12-06T08:22:59.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2017-12-06T09:10:54.000Z (about 7 years ago)
- Last Synced: 2024-04-24T23:40:59.607Z (8 months ago)
- Language: JavaScript
- Size: 24.4 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# Functional Branch
`unl` exports only one function that takes a `test`, a `left`, and a `right`
function and return a combined one that will run `left` if `test` returns falsy
and `right` otherwise# Example
```js
const unless = require('unl');const isOdd = x => x % 2;
const left = x => `${x} is not odd`;
const right = x => `${x} is not even`;const fn = unless(isOdd, left, right);
console.log(fn(2)); // returns 2 is not odd
console.log(fn(1)); // returns 1 is not even
```