Package Exports
- @voidvolker/is
Readme
is
Set of shortands of Object.prototype.toString for simple type check. Need to fast and basic type check of some data and don't want to include heavy libraries? You are welcome. Here is only few lines of code. In case if you need more complex data check - that set isn't what you looking for. Try to take a look to Schema, lodash and others.
Набор сокращений Object.prototype.toString для простой проверки типов. Нужна быстрая и простая проверка типа и не хочется подключать тяжелые комбайны? Эта библиотека именно то, что вам нужно. Если вам нужна более тщательная и сложная проверка данных - этот набор не то, что вы ищета. Попробуйте взглянуть на Schema, lodash или другие аналоги.
Install
npm i @voidvolker/isNo any additional dependencies is used.
Use
ES module:
import {
isBoolean,
isNumber,
isString,
isArray,
isObject,
isFunction,
typeGet
} from '@voidvolker/is'
console.log(isBoolean(true)
console.log(isString('string'))
console.log(typeGet([]))Require:
const {
isBoolean,
isNumber,
isString,
isArray,
isObject,
isFunction,
typeGet
} = require('@voidvolker/is') // -> dist/commonjs/is.cjs
console.log(isBoolean(true)
console.log(isString('string'))
console.log(typeGet([]))Coffee script:
import {
isBoolean
isNumber
isString
isArray
isObject
isFunction
typeGet
} from '@voidvolker/is'
console.log isBoolean true
console.log isString 'string'
console.log typeGet []Exports
isBoolean(v)isNumber(v)- Excludes NaN, includesNumber()type and InfinityisString(v)isArray(v)->Array.isArrayisObject(v)isFunction(v)typeGet(v)- returns string with string likeBoolean,Numberand etc. Warning! Useless for NaN:typeGet(NaN) === 'Number'
Exactly types checks
Run command to get full report for each value type results:
npm i -D
npm testDetails can be found in test/is.spec.coffee file.
Dev
To update dependencies use ncu module.
Build
npm run buildrollup and babel is used for bundling and transforming code for browsers. Take a look to dist folder and take what you need.
Only compile coffee:
npm run makeTest
npm testAnd command to watch tests in realtime:
npm run wtWatch
npm run w