npm install @eoln/is --save
run time type/class discovery by value inspection
and custom class checkers registry (scoped)
iz = require '@eoln/is'
class NewClass
iz.name new NewClass
#=> 'NewClass'
register custom NewClass
in global
scope instance/value
iz.register new NewClass
iz.NewClass new NewClass
#=> true
register custom NewestClass
in custom scope eoln
class NewestClass
iz.register new NewestClass, 'eoln'
iz.eoln.NewestClass new NewestClass
#=> true
do we have Array
?
iz.Array []
#=> true
do we have Object
?
iz.Object {}
#=> true
iz.Function Object
#=> true
do we have String
?
iz.String 'the-string'
#=> true
do we have RegExp
?
iz.RegExp /^i-am-regexp$/g
#=> true
do we have Date
?
iz.Date new Date()
#=> true
do we have Number
?
iz.Number 3.14
#=> true
iz.Number 1
#=> true
do we have Function
?
iz.Function (x) => x*x
#=> true
do we have Boolean
iz.Boolean 1 == 2
#=> true
iz.Boolean false
#=> true
do we have Undefined
?
iz.Undefined undefined
#=> true
do we have Null
?
iz.Null null
#=> true
do we have Symbol
?
iz.Symbol Symbol()
#=> true
prefix not
will negate checker
we don't have Function
on global
scope
iz.not.Symbol Symbol()
#=> false
iz.not.Symbol []
#=> true
negators in custom scope eoln
iz.eoln.not.NewestClass {}
#=> true
iz.eoln.not.NewestClass new NewestClass
#=> false