is-obj-type

1.0.0 • Public • Published

is-obj-type

Good judgment of object type.

install

$ npm install --save isType

Example

const is = require('is-obj-type');
console.log(is.num(2));
 
var some = function(){
    //...
}
var obj = new some();
var isSome = is("some");
console.log(isSome(obj));
 
class someCls{};
var someObj = new someCls();
var isSomeCls = is("someCls");
console.log(isSomeCls(someObj));
 
var isSomeOrCls = is.all("some","someCls");
console.log(isSomeOrCls(obj));
console.log(isSomeOrCls(someObj));

output

true // x5

Usage

const is = require('isType');

Standard object

is.num(1); // => true
is.str(""); // => true
is.bool(true); // => true
is.arr([]); // => true
is.null(null); // => true
is.func(()=>{}); // => true
is.obj({}); // => true
is.undefined(undefined); // => true
is.symbol(Symbol("symbol")); // => true
is.global(window); // Browser
is.global(global); // Node

Plain object pair object

is.plain(new function(){}) // => false
is.plain(Object.create(null)) // => false
is.plain({})// => true

Custom class

var some = function(){};
var sObj = new some();
var isSome = is("some");
isSome(sObj);// => true
 
class somecls{};
var clsObj = new somecls();
var isSomecls = is("somecls");
isSomecls(clsObj);// => true

mulit condition

var isSomeOrCls = is.all("some","somecls");
isSomeOrCls(sObj);// => true
isSomeOrCls(clsObj);// => true

Advanced

Function Class overloading

// ...

About

*npm(new release) need to pull dev-lib with cmd
npm i --only=dev

browserify

$ npm run browserify

test

$ npm run test

Package Sidebar

Install

npm i is-obj-type

Weekly Downloads

2

Version

1.0.0

License

GPL-3.0

Unpacked Size

46.7 kB

Total Files

7

Last publish

Collaborators

  • tacopie