should-type
Advanced tools
Comparing version 0.0.3 to 0.0.4
23
index.js
var toString = Object.prototype.toString; | ||
var isPromiseExist = typeof Promise !== 'undefined'; | ||
var isBufferExist = typeof Buffer !== 'undefined'; | ||
var types = { | ||
@@ -137,9 +134,17 @@ NUMBER: 'number', | ||
default: | ||
if(isPromiseExist && instance instanceof Promise && getType(instance.then) === FUNCTION && instance.then.length >= 2) return types.PROMISE; | ||
if((typeof Promise === types.FUNCTION && instance instanceof Promise) || (getType(instance.then) === types.FUNCTION && instance.then.length >= 2)) { | ||
return types.PROMISE; | ||
} | ||
if(isBufferExist && instance instanceof Buffer) return types.BUFFER; | ||
if(typeof Buffer !== 'undefined' && instance instanceof Buffer) { | ||
return types.BUFFER; | ||
} | ||
if(/^\[object HTML\w+Element\]$/.test(clazz)) return types.HTML_ELEMENT; | ||
if(/^\[object HTML\w+Element\]$/.test(clazz)) { | ||
return types.HTML_ELEMENT; | ||
} | ||
if(clazz === '[object Object]') return types.OBJECT; | ||
if(clazz === '[object Object]') { | ||
return types.OBJECT; | ||
} | ||
} | ||
@@ -149,2 +154,4 @@ } | ||
module.exports.type = types; | ||
Object.keys(types).forEach(function(typeName) { | ||
module.exports[typeName] = types[typeName]; | ||
}); |
{ | ||
"name": "should-type", | ||
"version": "0.0.3", | ||
"description": "Simple module to get instance type", | ||
"version": "0.0.4", | ||
"description": "Simple module to get instance type. Like a bit more advanced version of typeof", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"repository": { | ||
@@ -10,0 +7,0 @@ "type": "git", |
No tests
QualityPackage does not have any tests. This is a strong signal of a poorly maintained or low quality package.
Found 1 instance in 1 package
6499
142
1