Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

predicate

Package Overview
Dependencies
Maintainers
2
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

predicate

A set of predicate functions to improve your value testing and comparisons.

  • 0.10.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
5.9K
increased by17.64%
Maintainers
2
Weekly downloads
 
Created
Source

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.

Keywords

FAQs

Package last updated on 24 Oct 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc