Package Exports
- is-check
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (is-check) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
is-check
Check if the given value is of a specific type.
About
Provide a simple and clean way to check if a value matches a specific type. Abstract the usage of "typeof === '...'".
Installation
npm install is-checkModule Usage
var check = require('is-check');var myValue = 'something';
check.isArray(myValue);
check.isBoolean(myValue);
check.isFunction(myValue);
check.isNil(myValue);
check.isNull(myValue);
check.isNumber(myValue);
check.isObject(myValue);
check.isString(myValue);
check.isUndefined(myValue);Running the tests
From inside the root project folder run:
npm installand then if you are on a windows machine:
npm testif you are on a unix machine:
npm testUNIXSpec
TOC
- function isArray()
- function isBoolean()
- function isFunction()
- function isNill()
- function isNull()
- function isNumber()
- function isObject()
- function isString()
- function isUndefined()
function isArray()
returns true:
isArray([]) should be true.
check.isArray([]).should.be.ok;isArray([1]) should be true.
check.isArray([1]).should.be.ok;isArray([new Array()]) should be true.
check.isArray([new Array()]).should.be.ok;isArray([Array.prototype]) should be true.
check.isArray([Array.prototype]).should.be.ok;returns false:
isArray(37) should be false.
check.isArray(37).should.not.be.ok;isArray(3.14) should be false.
check.isArray(3.14).should.not.be.ok;isArray(Math.LN2) should be false.
check.isArray(Math.LN2).should.not.be.ok;isArray(Infinity) should be false.
check.isArray(Infinity).should.not.be.ok;isArray(Number(1)) should be false.
check.isArray(Number(1)).should.not.be.ok;isArray(NaN) should be false.
check.isArray(NaN).should.not.be.ok;isArray("") should be false.
check.isArray("").should.not.be.ok;isArray("bla") should be false.
check.isArray("bla").should.not.be.ok;isArray(typeof 1) should be false.
check.isArray(typeof 1).should.not.be.ok;isArray("abc") should be false.
check.isArray("abc").should.not.be.ok;isArray(false) should be false.
check.isArray(false).should.not.be.ok;isArray(false) should be false.
check.isArray(false).should.not.be.ok;isArray(Boolean(false)) should be false.
check.isArray(Boolean(false)).should.not.be.ok;isArray(Boolean(false)) should be false.
check.isArray(Boolean(false)).should.not.be.ok;isArray( new Boolean(false)) should be false.
check.isArray(Boolean( new Boolean(false))).should.not.be.ok;isArray(undefined) should be false.
check.isArray(undefined).should.not.be.ok;isArray(null) should be false.
check.isArray(null).should.not.be.ok;isArray({a:1}) should be false.
check.isArray({a:1}).should.not.be.ok;isArray(new Date()) should be false.
check.isArray(new Date()).should.not.be.ok;isArray(function(){}) should be false.
check.isArray(function(){}).should.not.be.ok;isArray(Math.sin) should be false.
check.isArray(Math.sin).should.not.be.ok;function isBoolean()
returns true:
isBoolean(true) should be true.
check.isBoolean(true).should.be.ok;isBoolean(false) should be true.
check.isBoolean(false).should.be.ok;isBoolean(Boolean(true)) should be true.
check.isBoolean(Boolean(true)).should.be.ok;isBoolean(Boolean(false)) should be true.
check.isBoolean(Boolean(false)).should.be.ok;returns false:
isBoolean(NaN) should be false.
check.isBoolean(NaN).should.not.be.ok;isBoolean(undefined) should be false.
check.isBoolean(undefined).should.not.be.ok;isBoolean(null) should be false.
check.isBoolean(null).should.not.be.ok;isBoolean({a:1}) should be false.
check.isBoolean({a:1}).should.not.be.ok;isBoolean(new Date()) should be false.
check.isBoolean(new Date()).should.not.be.ok;isBoolean(function(){}) should be false.
check.isBoolean(function(){}).should.not.be.ok;isBoolean(Math.sin) should be false.
check.isBoolean(Math.sin).should.not.be.ok;isBoolean([1, 2, 4]) should be false.
check.isBoolean([1, 2, 4]).should.not.be.ok;isBoolean(37) should be false.
check.isBoolean(37).should.not.be.ok;isBoolean(3.14) should be false.
check.isBoolean(3.14).should.not.be.ok;isBoolean(Math.LN2) should be false.
check.isBoolean(Math.LN2).should.not.be.ok;isBoolean(Infinity) should be false.
check.isBoolean(Infinity).should.not.be.ok;isBoolean(Number(1)) should be false.
check.isBoolean(Number(1)).should.not.be.ok;isBoolean("") should be false.
check.isBoolean("").should.not.be.ok;isBoolean("bla") should be false.
check.isBoolean("bla").should.not.be.ok;isBoolean(typeof 1) should be false.
check.isBoolean(typeof 1).should.not.be.ok;isBoolean("abc") should be false.
check.isBoolean("abc").should.not.be.ok;function isFunction()
returns true:
isFunction(function(){}) should be true.
check.isFunction(function(){}).should.be.ok;isFunction(Math.sin) should be true.
check.isFunction(Math.sin).should.be.ok;returns false:
isFunction(37) should be false.
check.isFunction(37).should.not.be.ok;isFunction(3.14) should be false.
check.isFunction(3.14).should.not.be.ok;isFunction(Math.LN2) should be false.
check.isFunction(Math.LN2).should.not.be.ok;isFunction(Infinity) should be false.
check.isFunction(Infinity).should.not.be.ok;isFunction(Number(1)) should be false.
check.isFunction(Number(1)).should.not.be.ok;isFunction(NaN) should be false.
check.isFunction(NaN).should.not.be.ok;isFunction("") should be false.
check.isFunction("").should.not.be.ok;isFunction("bla") should be false.
check.isFunction("bla").should.not.be.ok;isFunction(typeof 1) should be false.
check.isFunction(typeof 1).should.not.be.ok;isFunction("abc") should be false.
check.isFunction("abc").should.not.be.ok;isFunction(true) should be false.
check.isFunction(true).should.not.be.ok;isFunction(false) should be false.
check.isFunction(false).should.not.be.ok;isFunction(Boolean(true)) should be false.
check.isFunction(Boolean(true)).should.not.be.ok;isFunction(Boolean(false)) should be false.
check.isFunction(Boolean(false)).should.not.be.ok;isFunction( new Boolean(true)) should be false.
check.isFunction(Boolean( new Boolean(true))).should.not.be.ok;isFunction(undefined) should be false.
check.isFunction(undefined).should.not.be.ok;isFunction(null) should be false.
check.isFunction(null).should.not.be.ok;isFunction({a:1}) should be false.
check.isFunction({a:1}).should.not.be.ok;isFunction(new Date()) should be false.
check.isFunction(new Date()).should.not.be.ok;isFunction([1, 2, 4]) should be false.
check.isFunction([1, 2, 4]).should.not.be.ok;function isNill()
returns true:
isNil(null) should be true.
check.isNil(null).should.be.ok;isNil(undefined) should be true.
check.isNil(undefined).should.be.ok;returns false:
isNil(NaN) should be false.
check.isNil(NaN).should.not.be.ok;isNil("") should be false.
check.isNil("").should.not.be.ok;isNil("bla") should be false.
check.isNil("bla").should.not.be.ok;isNil(typeof 1) should be false.
check.isNil(typeof 1).should.not.be.ok;isNil("abc") should be false.
check.isNil("abc").should.not.be.ok;isNil(true) should be false.
check.isNil(true).should.not.be.ok;isNil(false) should be false.
check.isNil(false).should.not.be.ok;isNil(Boolean(true)) should be false.
check.isNil(Boolean(true)).should.not.be.ok;isNil(Boolean(false)) should be false.
check.isNil(Boolean(false)).should.not.be.ok;isNil( new Boolean(true)) should be false.
check.isNil(Boolean( new Boolean(true))).should.not.be.ok;isNil({a:1}) should be false.
check.isNil({a:1}).should.not.be.ok;isNil(new Date()) should be false.
check.isNil(new Date()).should.not.be.ok;isNil(function(){}) should be false.
check.isNil(function(){}).should.not.be.ok;isNil(Math.sin) should be false.
check.isNil(Math.sin).should.not.be.ok;isNil([1, 2, 4]) should be false.
check.isNil([1, 2, 4]).should.not.be.ok;isNil(37) should be false.
check.isNil(37).should.not.be.ok;isNil(3.14) should be false.
check.isNil(3.14).should.not.be.ok;isNil(Math.LN2) should be false.
check.isNil(Math.LN2).should.not.be.ok;isNil(Infinity) should be false.
check.isNil(Infinity).should.not.be.ok;isNil(Number(1)) should be false.
check.isNil(Number(1)).should.not.be.ok;function isNull()
returns true:
isNull(null) should be true.
check.isNull(null).should.be.ok;returns false:
isNull(37) should be false.
check.isNull(37).should.not.be.ok;isNull(3.14) should be false.
check.isNull(3.14).should.not.be.ok;isNull(Math.LN2) should be false.
check.isNull(Math.LN2).should.not.be.ok;isNull(Infinity) should be false.
check.isNull(Infinity).should.not.be.ok;isNull(Number(1)) should be false.
check.isNull(Number(1)).should.not.be.ok;isNull(NaN) should be false.
check.isNull(NaN).should.not.be.ok;isNull("") should be false.
check.isNull("").should.not.be.ok;isNull("bla") should be false.
check.isNull("bla").should.not.be.ok;isNull(typeof 1) should be false.
check.isNull(typeof 1).should.not.be.ok;isNull("abc") should be false.
check.isNull("abc").should.not.be.ok;isNull(true) should be false.
check.isNull(true).should.not.be.ok;isNull(false) should be false.
check.isNull(false).should.not.be.ok;isNull(Boolean(true)) should be false.
check.isNull(Boolean(true)).should.not.be.ok;isNull(Boolean(false)) should be false.
check.isNull(Boolean(false)).should.not.be.ok;isNull( new Boolean(true)) should be false.
check.isNull(Boolean( new Boolean(true))).should.not.be.ok;isNull(undefined) should be false.
check.isNull(undefined).should.not.be.ok;isNull({a:1}) should be false.
check.isNull({a:1}).should.not.be.ok;isNull(new Date()) should be false.
check.isNull(new Date()).should.not.be.ok;isNull(function(){}) should be false.
check.isNull(function(){}).should.not.be.ok;isNull(Math.sin) should be false.
check.isNull(Math.sin).should.not.be.ok;isNull([1, 2, 4]) should be false.
check.isNull([1, 2, 4]).should.not.be.ok;function isNumber()
returns true:
isNumber(37) should be true.
check.isNumber(37).should.be.ok;isNumber(3.14) should be true.
check.isNumber(3.14).should.be.ok;isNumber(Math.LN2) should be true.
check.isNumber(Math.LN2).should.be.ok;isNumber(Infinity) should be true.
check.isNumber(Infinity).should.be.ok;isNumber(Number(1)) should be true.
check.isNumber(Number(1)).should.be.ok;returns false:
isNumber(NaN) should be false.
check.isNumber(NaN).should.not.be.ok;isNumber("") should be false.
check.isNumber("").should.not.be.ok;isNumber("bla") should be false.
check.isNumber("bla").should.not.be.ok;isNumber(typeof 1) should be false.
check.isNumber(typeof 1).should.not.be.ok;isNumber("abc") should be false.
check.isNumber("abc").should.not.be.ok;isNumber(true) should be false.
check.isNumber(true).should.not.be.ok;isNumber(false) should be false.
check.isNumber(false).should.not.be.ok;isNumber(Boolean(true)) should be false.
check.isNumber(Boolean(true)).should.not.be.ok;isNumber(Boolean(false)) should be false.
check.isNumber(Boolean(false)).should.not.be.ok;isNumber( new Boolean(true)) should be false.
check.isNumber(Boolean( new Boolean(true))).should.not.be.ok;isNumber(undefined) should be false.
check.isNumber(undefined).should.not.be.ok;isNumber(null) should be false.
check.isNumber(null).should.not.be.ok;isNumber({a:1}) should be false.
check.isNumber({a:1}).should.not.be.ok;isNumber(new Date()) should be false.
check.isNumber(new Date()).should.not.be.ok;isNumber(function(){}) should be false.
check.isNumber(function(){}).should.not.be.ok;isNumber(Math.sin) should be false.
check.isNumber(Math.sin).should.not.be.ok;isNumber([1, 2, 4]) should be false.
check.isNumber([1, 2, 4]).should.not.be.ok;function isObject()
returns true:
isObject({a:1}) should be true.
check.isObject({a:1}).should.be.ok;isObject(new Date()) should be true.
check.isObject(new Date()).should.be.ok;isObject(new Boolean(true)) should be true.
check.isObject(new Boolean(true)).should.be.ok;returns false:
isObject(37) should be false.
check.isObject(37).should.not.be.ok;isObject(3.14) should be false.
check.isObject(3.14).should.not.be.ok;isObject(Math.LN2) should be false.
check.isObject(Math.LN2).should.not.be.ok;isObject(Infinity) should be false.
check.isObject(Infinity).should.not.be.ok;isObject(Number(1)) should be false.
check.isObject(Number(1)).should.not.be.ok;isObject(NaN) should be false.
check.isObject(NaN).should.not.be.ok;isObject("") should be false.
check.isObject("").should.not.be.ok;isObject("bla") should be false.
check.isObject("bla").should.not.be.ok;isObject(typeof 1) should be false.
check.isObject(typeof 1).should.not.be.ok;isObject("abc") should be false.
check.isObject("abc").should.not.be.ok;isObject(true) should be false.
check.isObject(true).should.not.be.ok;isObject(false) should be false.
check.isObject(false).should.not.be.ok;isObject(Boolean(true)) should be false.
check.isObject(Boolean(true)).should.not.be.ok;isObject(Boolean(false)) should be false.
check.isObject(Boolean(false)).should.not.be.ok;isObject( new Boolean(true)) should be false.
check.isObject(Boolean( new Boolean(true))).should.not.be.ok;isObject(undefined) should be false.
check.isObject(undefined).should.not.be.ok;isObject(null) should be false.
check.isObject(null).should.not.be.ok;isObject(function(){}) should be false.
check.isObject(function(){}).should.not.be.ok;isObject(Math.sin) should be false.
check.isObject(Math.sin).should.not.be.ok;isObject([1, 2, 4]) should be false.
check.isObject([1, 2, 4]).should.not.be.ok;function isString()
returns true:
isString("") should be true.
check.isString("").should.be.ok;isString("bla") should be true.
check.isString("bla").should.be.ok;isString(typeof 1) should be true.
check.isString(typeof 1).should.be.ok;isString("abc") should be true.
check.isString("abc").should.be.ok;returns false:
isString(NaN) should be false.
check.isString(NaN).should.not.be.ok;isString(true) should be false.
check.isString(true).should.not.be.ok;isString(false) should be false.
check.isString(false).should.not.be.ok;isString(Boolean(true)) should be false.
check.isString(Boolean(true)).should.not.be.ok;isString(Boolean(false)) should be false.
check.isString(Boolean(false)).should.not.be.ok;isString( new Boolean(true)) should be false.
check.isString(Boolean( new Boolean(true))).should.not.be.ok;isString(undefined) should be false.
check.isString(undefined).should.not.be.ok;isString(null) should be false.
check.isString(null).should.not.be.ok;isString({a:1}) should be false.
check.isString({a:1}).should.not.be.ok;isString(new Date()) should be false.
check.isString(new Date()).should.not.be.ok;isString(function(){}) should be false.
check.isString(function(){}).should.not.be.ok;isString(Math.sin) should be false.
check.isString(Math.sin).should.not.be.ok;isString([1, 2, 4]) should be false.
check.isString([1, 2, 4]).should.not.be.ok;isString(37) should be false.
check.isString(37).should.not.be.ok;isString(3.14) should be false.
check.isString(3.14).should.not.be.ok;isString(Math.LN2) should be false.
check.isString(Math.LN2).should.not.be.ok;isString(Infinity) should be false.
check.isString(Infinity).should.not.be.ok;isString(Number(1)) should be false.
check.isString(Number(1)).should.not.be.ok;function isUndefined()
returns true:
isUndefined(undefined) should be true.
check.isUndefined(undefined).should.be.ok;returns false:
isUndefined(37) should be false.
check.isUndefined(37).should.not.be.ok;isUndefined(3.14) should be falsw.
check.isUndefined(3.14).should.not.be.ok;isUndefined(Math.LN2) should be false.
check.isUndefined(Math.LN2).should.not.be.ok;isUndefined(Infinity) should be false.
check.isUndefined(Infinity).should.not.be.ok;isUndefined(Number(1)) should be false.
check.isUndefined(Number(1)).should.not.be.ok;isUndefined(NaN) should be false.
check.isUndefined(NaN).should.not.be.ok;isUndefined("") should be false.
check.isUndefined("").should.not.be.ok;isUndefined("bla") should be false.
check.isUndefined("bla").should.not.be.ok;isUndefined(typeof 1) should be false.
check.isUndefined(typeof 1).should.not.be.ok;isUndefined("abc") should be false.
check.isUndefined("abc").should.not.be.ok;isUndefined(true) should be false.
check.isUndefined(true).should.not.be.ok;isUndefined(false) should be false.
check.isUndefined(false).should.not.be.ok;isUndefined(Boolean(true)) should be false.
check.isUndefined(Boolean(true)).should.not.be.ok;isUndefined(Boolean(false)) should be false.
check.isUndefined(Boolean(false)).should.not.be.ok;isUndefined( new Boolean(true)) should be false.
check.isUndefined(Boolean( new Boolean(true))).should.not.be.ok;isUndefined(null) should be false.
check.isUndefined(null).should.not.be.ok;isUndefined({a:1}) should be false.
check.isUndefined({a:1}).should.not.be.ok;isUndefined(new Date()) should be false.
check.isUndefined(new Date()).should.not.be.ok;isUndefined(function(){}) should be false.
check.isUndefined(function(){}).should.not.be.ok;isUndefined(Math.sin) should be false.
check.isUndefined(Math.sin).should.not.be.ok;isUndefined([1, 2, 4]) should be false.
check.isUndefined([1, 2, 4]).should.not.be.ok;