predicate functions collection
npm install toxic-predicate-functions --save
if you are using flow
, you should import our flow defination, by adding this to your .flowconfig
.
[ignore]
[include]
[libs]
./node_modules/toxic-predicate-functions/lib/index.flow.js
[options]
[lints]
to check whether the object is defined or not
Parameters
obj
any
Returns boolean
is void element or not ? Means it will return true when val is undefined or null
Parameters
obj
any
Returns boolean
to check whether a variable is array
Parameters
arr
any
Returns boolean
is it a function or not
Parameters
obj
any
Returns boolean
is it an object or not
Parameters
obj
any
Returns boolean
to tell you if it's a real number
Parameters
obj
any
Returns boolean
to tell you if the val can be transfer into number
Parameters
obj
any
Returns boolean
is it an interget or not
Parameters
num
any
Returns boolean
return true when the value is "", {}, [], 0, null, undefined, false.
Parameters
obj
any
Returns boolean
is it an event or not
Parameters
obj
any
Returns boolean
is it a blob
Parameters
obj
any
Returns boolean
is it a file uploaded by user through file inpue
Parameters
obj
any
Returns boolean
is it a date
Parameters
obj
any
Returns boolean
is it a string
Parameters
str
any
Returns boolean
is Boolean or not
Parameters
bool
any
Returns boolean
is a promise or not
Parameters
obj
any
Returns boolean
is Primitive type or not, whick means it will return true when data is number/string/boolean/undefined/null
Parameters
val
any
Returns boolean
is it an url, but this test require the url to have an protocol
Parameters
str
any
Returns boolean
to test if a HTML node
Parameters
obj
any
Returns boolean
to test if a HTML element
Parameters
obj
any
Returns boolean
check if node A is node B's parent or not
Parameters
Returns boolean
check if node B is node A's posterrity or not
Parameters
Returns boolean
check if the string is an HTMLString
Parameters
str
string
Returns boolean
check if is an error
Parameters
val
any
Returns boolean
check if is an RegExp
Parameters
val
any
Returns boolean