1.1.0 • Published 6 years ago

@eoln/is v1.1.0

Weekly downloads
-
License
GPL-3.0
Repository
github
Last release
6 years ago

@eoln/is

install mantra

npm install @eoln/is --save

TL;DR

run time type/class discovery by value inspection
and custom class checkers registry (scoped)

usage examples:

iz = require '@eoln/is'

name - class/type name discovery from instance/value

class NewClass
iz.name new NewClass
#=> 'NewClass'

register - checkers registry

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

checkers

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

not - checker negator

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
1.1.0

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago