Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

should-type

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

should-type - npm Package Compare versions

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",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc