Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Common predicates for Node.js and the browser
JavaScript
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
.gitignore
.npmignore
.travis.yml
History.md
Makefile
README.md
component.json
index.js
package.json
test.js

README.md

predicates

Common predicates for Node.js and the browser

Build Status

browser support

install

npm

$ npm install predicates --save

component

$ component install jwerle/predicates --save

bower

$ bower install predicates

usage

var isString = require('predicates').isString
  , isBoolean = require('predicates').isBoolean
  , isNull = require('predicates').isNull

assert(isString('123'));
assert(isBoolean(true));
assert(isNull(null));

api

All predicates return a boolean

predicate(name fn)

Creates a new predicate

  • name - The name of the predicate
  • fn - The predicate function

example

var isNode = predicate('node', function (a) {
  return a instanceof Node;
});

assert(isNode(document.getElementById('#node')));

Common predicates

  • isString(a) - asserts input is a string
  • isNumber(a) - asserts input is a number
  • isBoolean(a) - asserts input is a boolean
  • isFunction(a)- asserts input is a function
  • isObject(a) - asserts input is an object
  • isArray(a) - asserts input is an array
  • isDate(a) - asserts input is a date instance
  • isNaN(a) - asserts input is NaN
  • isUndefined(a) - asserts input is undefined
  • isNull(a) - asserts input is null
  • isEmpty(a) - asserts input is empty (empty array, empty string, or falsy)

license

MIT

Something went wrong with that request. Please try again.