ayoub 415ac645b3 Auto COMMIT for build : 7160 \n commit by: a.hassani <hassani.ayoub@gmail.com> \n with message : Update package version to 0.0.4 | 1 year ago | |
---|---|---|
README.md | 1 year ago | |
index.js | 1 year ago | |
package.json | 1 year ago |
just a function type
that is less-broken typeof
, and a little bit more precise.
npm install --save @d3v4pp/type
var type = require('@d3v4pp/type');
var obj = new Date;
if (type(obj) == 'date') {
...
}
type(new Date) == 'date'
type({}) == 'object'
type(null) == 'null'
type(undefined) == 'undefined'
type("hey") == 'string'
type(true) == 'boolean'
type(false) == 'boolean'
type(12) == 'number'
type(type) == 'function'
type(/asdf/) == 'regexp'
type((function(){ return arguments })()) == 'arguments'
type([]) == 'array'
type(document.createElement('div')) == 'element'
type(NaN) == 'nan'
type(new Error('Ups! Something wrong...')) == 'error'
type(new Buffer) == 'buffer'
BY : @d3v4pp