Package Exports
- is-funcs
- is-funcs/is-array
- is-funcs/is-boolean
- is-funcs/is-defined
- is-funcs/is-gte
- is-funcs/is-node
- is-funcs/is-number
- is-funcs/is-object
- is-funcs/is-string
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-funcs) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
is-funcs
A very limited subset of type checking functions I use every day
Install
npm i is-funcsPackage on npm
require
// require all functions
const isObject = require('is-funcs').isObject
// require only the single function (recommanded)
const isObject = require('is-funcs/is-object')API
- is
- isArray
- isBoolean
- isDefined
- isFloat
- isFunction
- isGt
- isGte
- isInteger
- isLt
- isLte
- isNode
- isNumber
- isObject
- isString
is(str, data)
Execute one or more check on data, based on str
const is = require('is-funcs/is')
// true
is('array', ['a'])
// false
is('array', [])
// true
is('array:false', [])
// true
is('lt:3', 2)
// false
is('lt:3', 5)
// true
is('float lte:1 gte:-1', -0.09)
// false
is('float lte:1 gte:-1', -1)isArray(data, [check])
Check if data is an Array and his length is > 0
The argument check is optional, default to true
If check is false, the length is not tested
const isArray = require('is-funcs/is-array')
// false
isArray({a:1})
// true
isArray(['a'])
// false
isArray([])
// true
isArray([], false)isBoolean(data)
Check if data is a Boolean
const isBoolean = require('is-funcs/is-boolean')
// false
isBoolean({a:1})
// true
isBoolean(true)
// true
isBoolean(false)isDefined(data)
Check if data is defined
Return true if
datais a Number and it's notNaNdatais a Plain Object and has at least 1 keydatais an Array and is length is > 0datais a String and is trimmed length is > 0
Otherwise return false
const isDefined = require('is-funcs/is-defined')
// false
isDefined(NaN)
// true
isDefined(0)
// true
isDefined(1)
// false
isDefined({})
// true
isDefined({a:1})
// false
isDefined([])
// true
isDefined(['a'])
// false
isDefined('')
// false
isDefined(' ')
// true
isDefined('a')isFloat(data)
Check if data is a float Number
const isFloat = require('is-funcs/is-float')
// false
isFloat('abc')
// false
isFloat(12)
// true
isFloat(12.3)isFunction(data)
Check if data is a Function
const isFunction = require('is-funcs/is-function')
// false
isFunction(12.3)
// true
isFunction(function() {})isGt(data, than)
Check if data is a greater than than
const isGt = require('is-funcs/is-gt')
// true
isGt(2, 1)
// false
isGt(2, 3)isGte(data, than)
Check if data is a greater than or equal than
const isGte = require('is-funcs/is-gte')
// true
isGte(3, 2)
// true
isGte(2, 2)
// false
isGte(2, 3)isInteger(data)
Check if data is an integer Number
const isInteger = require('is-funcs/is-integer')
// true
isGt(2)
// false
isGt(2.34)isLt(data, than)
Check if data is a lower than than
const isLt = require('is-funcs/is-lt')
// true
isLt(1, 2)
// false
isLt(3, 2)isLte(data, than)
Check if data is a lower than or equal than
const isLte = require('is-funcs/is-lte')
// true
isLte(1, 2)
// true
isLte(2, 2)
// false
isLte(3, 2)isNode(data)
Check if data is a Html Element landed in the document.body
- data nodeType must be 1
- non visual element like
styleorstyleare excluded
const isNode = require('is-funcs/is-node')
// true
isNode(document.querySelector('div'))
// false
isNode(document.createElement('div'))isNumber(data, [check])
Check if data is a Number, not equals to NaN
The argument check is optional, default to true
If check is false, the isNaN step is ignored
const isNumber = require('is-funcs/is-number')
// false
isNumber([1])
// true
isNumber(1)
// true
isNumber(2.34)
// false
isNumber(NaN)isObject(data, [check])
Check if data is an Plain Object and has at least 1 key
The argument check is optional, default to true
If check is false, the keys count is not tested
const isObject = require('is-funcs/is-object')
// false
isObject([1])
// true
isObject({a:1})
// false
isObject({})
// true
isObject({}, false)isString(data, [check])
Check if data is an String and his trimmed length is > 0
The argument check is optional, default to true
If check is false, the trimmed length is not tested
const isString = require('is-funcs/is-string')
// false
isString({a:1})
// true
isString('abc')
// false
isString('')
// false
isString(' ')
// true
isString(' ', false)License
MIT