Collection of functions for basic type checking.
Install with npm
npm install vanilla-type-check
// import functions (better tree-shaking)
import { isArray } from 'vanilla-type-check/isArray';
import { isBoolean } from 'vanilla-type-check/isBoolean';
import { isDom } from 'vanilla-type-check/isDom';
import { isEmpty } from 'vanilla-type-check/isEmpty';
import { isFunction } from 'vanilla-type-check/isFunction';
import { isInt } from 'vanilla-type-check/isInt';
import { isNumber } from 'vanilla-type-check/isNumber';
import { isNumeric } from 'vanilla-type-check/isNumeric';
import { isObject } from 'vanilla-type-check/isObject';
import { isPlainObject } from 'vanilla-type-check/isPlainObject';
import { isString } from 'vanilla-type-check/isString';
// use the provided functions to check the type of an object (all of them return a Boolean)
isArray(foo);
isBoolean(foo);
isDom(foo);
isEmpty(foo);
isFunction(foo);
isInt(foo);
isNumber(foo);
isNumeric(foo);
isObject(foo);
isPlainObject(foo);
isString(foo);
Install dev dependencies
npm install -d && npm test
- Other functions also return
value is TYPE
.
isArray(x: any)
now returnsx is any[]
to let typescript compiler know that isx
an array
- Rewritten in typescript
- Removed dependencies
- Auto generated documentation
- New functions:
isBoolean
,isPlainObject
- Changed functions:
isEmptyObject
is nowisEmpty
and works with objects, arrays and DOM nodes - Each function is exported from a different file, to help treeshaking (old way still works)
- Improved test cases
// import all functions
import typecheck from 'vanilla-type-check';
typecheck.isArray(foo);
typecheck.isBoolean(foo);
typecheck.isDom(foo);
typecheck.isEmpty(foo);
typecheck.isFunction(foo);
typecheck.isInt(foo);
typecheck.isNumber(foo);
typecheck.isNumeric(foo);
typecheck.isObject(foo);
typecheck.isPlainObject(foo);
typecheck.isString(foo);