assert-is
v0.5.0
Published
is mixin for assert
Downloads
11
Readme
assert-is
Getting Started
Install the module with: npm install assert-is
API
It modifies is
API by taking one extra argument being either a string or a callback.
If a string is given, then it will be used as the message for the error that will be thrown in case the assertion fails..
If a callback is passed then it will be called in case the assertion fails.
general
assert.isA
(value, type, message) orassert.isType
(value, type, message)assert.isDefined
(value, message)assert.isEmpty
(value, message)assert.isEqual
(value, other, message)assert.isHosted
(value, host, message)assert.isInstance
(value, constructor, message)assert.isInstanceof
(value, constructor, message) - deprecated, because in ES3 browsers, "instanceof" is a reserved wordassert.isNil
(value, message)assert.isNull
(value, message) - deprecated, because in ES3 browsers, "null" is a reserved wordassert.isUndef
(value, message)assert.isUndefined
(value, message) - deprecated, because in ES3 browsers, "undefined" is a reserved word
arguments
isArgs
(value, message)
array
isArray
(value, message)isArraylike
(value, message)
boolean
isBool
(value, message)
date
assert.isDate
(value, message)
element
assert.isElement
(value, message)
error
assert.isError
(value, message)
function
assert.isFn
(value, message)
number
assert.isNumber
(value, message)assert.isInfinite
(value, message)assert.isDecimal
(value, message)assert.isDivisibleBy
(value, n, message)assert.isInteger
(value, message)assert.isInt
(value, message) - deprecated, because in ES3 browsers, "int" is a reserved wordassert.isMaximum
(value, others, message)assert.isMinimum
(value, others, message)assert.isNan
(value, message)assert.isEven
(value, message)assert.isOdd
(value, message)assert.isGe
(value, other, message)assert.isGt
(value, other, message)assert.isLe
(value, other, message)assert.isLt
(value, other, message)assert.isWithin
(value, start, finish, message)
object
assert.isObject
(value, message)
regexp
assert.isRegexp
(value, message)
string
assert.isString
(value, message)
encoded binary
assert.isBase64
(value, message)assert.isHex
(value, message)
ES6 Symbols
assert.isSymbol
(value, message)
Examples
var assert = require('assert-is');
assert.isDefined({}, 'This is OK.');
assert.isObject("foo", '"foo" is not an object');
Contributing
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using Grunt.
Release History
(Nothing yet)
License
Copyright (c) 2015 goliatone
Licensed under the MIT license.
https://github.com/tj/better-assert/blob/master/index.js