a predicate library for Typescript
npm install predicate-ts --save
import {Predicate} from 'predicate-ts'
// `AND` example
const gt10 = Predicate.build<number>(n => n > 10);
const lt20 = Predicate.build<number>(n => n < 20);
gt10.and(lt20).test(15) // -> true
gt10.and(lt20).test(0) // -> false
// `OR` example
const lt10 = Predicate.build<number>(n => n < 10);
const gt20 = Predicate.build<number>(n => n > 20);
lt10.or(gt20).test(15) // -> false
lt10.or(gt20).test(0) // -> true
lt10.or(gt20).test(30) // -> true
// `NOT` example
lt10.or(lt20.negate()).test(15) // -> false
lt10.or(lt20.negate()).test(0) // -> true
lt10.or(lt20.negate()).test(30) // -> true
npm install
npm test
- 0.1.0
- still under development
Distributed under the MIT license. See LICENSE
for more information.
- Fork it (https://github.com/trinin/predicate-ts/fork)
- Create your feature branch (
git checkout -b feature/fooBar
) - Commit your changes (
git commit -am 'Add some fooBar'
) - Push to the branch (
git push origin feature/fooBar
) - Create a new Pull Request