npm.io
2.1.0 • Published 9 years ago

and-or-not

Licence
MIT
Version
2.1.0
Deps
0
Vulns
0
Weekly
0
Stars
1

and-or-not

Example

The following code creates a predicate that returns true for numbers less than 15, and not less than 5, and divisible by either 2 or 3.

import { and, or, not } from 'and-or-not';
import { $lt, $mod } from 'and-or-not';

const predicate = and($lt(15), 
                      not($lt(5)),
                      or($mod(2), $mod(3)));

const values = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20];

const matches = values.filter(predicate);
  
console.log(matches) // [6,8,9,10,12,14]

Keywords