@eoln/is
eoln's type recognition utility
Last updated 2 years ago by eoln .
GPL-3.0 · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @eoln/is 
SYNC missed versions from official npm registry.

@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

Current Tags

  • 1.1.0                                ...           latest (2 years ago)

3 Versions

  • 1.1.0                                ...           2 years ago
  • 1.0.3                                ...           2 years ago
  • 1.0.2                                ...           2 years ago
Maintainers (1)
Downloads
Today 0
This Week 1
This Month 6
Last Day 1
Last Week 3
Last Month 1
Dependencies (1)
Dev Dependencies (2)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |