0.10.1 • Published 10 years ago

is-predicate v0.10.1

Weekly downloads
294
License
MIT
Repository
-
Last release
10 years ago

Build Status NPM

is.js - Adding clarity and conciseness to your JS through predicates

is.js is a predicate library for JS. is doesn't have any dependencies which makes it easy to integrate into new and existing projects.

Docs

landau.github.io/is

install

npm install --save is-predicate

or

download the file from the dist directory

Usage

is.equal(1, 1); // true
is.not.pos(-1); // true
is.ternary(true, 'foo', 'bar'); // foo
is.fn(function () {}); // true
is.not.equal(1, 3); // true

Every/Some

Every and some are functions that allow you to chain predicate calls. The calls are not evaluated until .val() is executed on the chain.

// All evaluations must be true
is.every().equal(1, 1).contains([1, 2, 3], 2).val(); // true
is.all().equal(1, 5).contains([1, 2, 3], 2).val(); // false

// At least one eval must be true
is.some().equal(1, 1).contains([1, 2, 3], 2).val(); // true
is.any().equal(1, 5).contains([1, 2, 3], 2).val(); // true
is.some().equal(1, 5).contains([1, 2, 3], 5).val(); // false

Alternaively to .val you can execute valueOf

// All evaluations must be true
!!is.every().equal(1, 1).contains([1, 2, 3], 2); // true

Notice the alias of all/any if you prefer that flavor

NOTE: Chaining doesnt work with .not yet.

Author

Trevor Landau

contributing

  • Suggestions welcome!
  • Tests!
  • Ping me on twitter if I take too long to respond! That probably means I missed the alert/email.

Tests

To run tests, install devDeps and type npm ts

Building

To build, type npm run build.

This will create a UMDified version of is in the dist directory along with a minified version.

0.10.1

10 years ago

0.10.0

10 years ago

0.9.0

10 years ago

0.8.2

10 years ago

0.8.1

10 years ago

0.8.0

10 years ago

0.7.3

10 years ago

0.7.2

10 years ago

0.7.1

10 years ago

0.7.0

10 years ago

0.6.0

10 years ago

0.5.1

10 years ago

0.5.0

10 years ago

0.4.0

10 years ago

0.3.1

10 years ago

0.3.0

10 years ago

0.2.0

10 years ago

0.2.1

10 years ago

0.1.1

10 years ago

0.1.0

10 years ago