pred

Predicates for JavaScript.

Synopsis

pred is a library of JavaScript predicates (functions that test their input and return a boolean).

Install

npm install pred
git clone https://github.com/pluma/pred.git
cd pred
npm install
make test

API

Returns a predicate that returns true if all of the predicates return true for the given input.

Returns a predicate that returns true if any of the predicates return true for the given input.

Returns a predicate that returns true if the input is identical to the given value (using === strict equal comparison).

Returns a predicate that returns true if the input is equivalent to the given value.

Example:

console.log(deepEquals({a: {b: ['c']}})({a: {b: ['c']}})); // true 

Returns a predicate that returns true if the input is greater than (but not equal to) the given value.

Returns a predicate that returns true if the input is less than (but not equal to) the given value.

Returns a predicate that returns true if the input is greater than (or equal to) the given minValue but less than (but not equal to) the given maxValue.

Returns a predicate that returns true if the input is an object that has a property with the given name.

Returns a predicate that returns true if the input is an object that has a property with each of the given names.

Returns a predicate that returns true if the input is an object that has a property matching the given properties (name/value mapping).

Returns a predicate that returns true if the input value matches the given regular expression.

Returns a predicate that returns true if the input value is an instance of the given constructor function.

Returns a predicate that returns true if the input value is the prototype of the given object.

Returns a predicate that returns true if the given prototype is the prototype of the input value.

Returns true if the input is falsey (i.e. evaluates as boolean false).

Returns true if the input is truthy (i.e. evaluates as boolean true).

Returns true if the input is array-like and all of its items are equal, or if it is not array-like.

Returns true if the given value is an Array.

Returns true if the given value is an Array or an object with a numeric length property.

Returns true if the given value is a Boolean.

Returns true if the given value is falsey, an array-like object with length zero or an object with no properties.

Returns true if the given value is a Function.

Returns true if the given value is NaN.

Returns true if the given value is null.

Returns true if the given value is a number other than NaN.

Returns true if the given value is an object other than null.

Returns true if the given value is an instance of Object.

Returns true if the given value is a string.

Returns true if the given value is .

Unlicense

This is free and unencumbered public domain software. For more information, see http://unlicense.org/ or the accompanying UNLICENSE file.