should-type
Advanced tools
Comparing version 1.3.0 to 1.4.0
@@ -46,5 +46,3 @@ 'use strict'; | ||
var toString = Object.prototype.toString; | ||
/** | ||
/* | ||
* Simple data function to store type information | ||
@@ -103,2 +101,6 @@ * @param {string} type Usually what is returned from typeof | ||
var toString = Object.prototype.toString; | ||
/** | ||
@@ -118,2 +120,11 @@ * Function to store type checks | ||
addBeforeFirstMatch: function(obj, func) { | ||
var match = this.getFirstMatch(obj); | ||
if (match) { | ||
this.checks.splice(match.index, 0, func); | ||
} else { | ||
this.add(func); | ||
} | ||
}, | ||
addTypeOf: function(type, res) { | ||
@@ -135,3 +146,3 @@ return this.add(function(obj, tpeOf) { | ||
getType: function(obj) { | ||
getFirstMatch: function(obj) { | ||
var typeOf = typeof obj; | ||
@@ -143,6 +154,10 @@ var cls = toString.call(obj); | ||
if (typeof res !== 'undefined') { | ||
return res; | ||
return { result: res, func: this.checks[i], index: i }; | ||
} | ||
} | ||
}, | ||
getType: function(obj) { | ||
var match = this.getFirstMatch(obj); | ||
return match && match.result; | ||
} | ||
@@ -149,0 +164,0 @@ }; |
@@ -44,5 +44,3 @@ var types = { | ||
var toString = Object.prototype.toString; | ||
/** | ||
/* | ||
* Simple data function to store type information | ||
@@ -101,2 +99,6 @@ * @param {string} type Usually what is returned from typeof | ||
var toString = Object.prototype.toString; | ||
/** | ||
@@ -116,2 +118,11 @@ * Function to store type checks | ||
addBeforeFirstMatch: function(obj, func) { | ||
var match = this.getFirstMatch(obj); | ||
if (match) { | ||
this.checks.splice(match.index, 0, func); | ||
} else { | ||
this.add(func); | ||
} | ||
}, | ||
addTypeOf: function(type, res) { | ||
@@ -133,3 +144,3 @@ return this.add(function(obj, tpeOf) { | ||
getType: function(obj) { | ||
getFirstMatch: function(obj) { | ||
var typeOf = typeof obj; | ||
@@ -141,6 +152,10 @@ var cls = toString.call(obj); | ||
if (typeof res !== 'undefined') { | ||
return res; | ||
return { result: res, func: this.checks[i], index: i }; | ||
} | ||
} | ||
}, | ||
getType: function(obj) { | ||
var match = this.getFirstMatch(obj); | ||
return match && match.result; | ||
} | ||
@@ -147,0 +162,0 @@ }; |
{ | ||
"name": "should-type", | ||
"version": "1.3.0", | ||
"version": "1.4.0", | ||
"description": "Simple module to get instance type. Like a bit more advanced version of typeof", | ||
@@ -36,4 +36,4 @@ "main": "cjs/should-type.js", | ||
"eslint-config-shouldjs": "^1.0.2", | ||
"rollup": "^0.34.3" | ||
"rollup": "^0.34.7" | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
15945
461