landau / predicate

Adding clarity and conciseness to your JS through predicates

Home Page:http://landau.github.io/predicate

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

operators "or" and "and"

lybo opened this issue · comments

Regarding this article https://codepen.io/Universalist/post/predicates-in-javascript
You can include or and and predicates with multiple args

    function or(...args) {
        return function(x) {
            return args.some(fn => fn(x));
        }
    }

    function and(...args) {
        return function(x) {
            return args.every(fn => fn(x));
        }
    }
commented

Good idea! Implemented.

https://landau.github.io/predicate/#and
https://landau.github.io/predicate/#or

Released in version 1.1.0. Use version 1.1.1 for a perf fix in chaining.

Thanks!