type-of-is
Advanced tools
Comparing version 3.1.2 to 3.1.3
136
index.js
@@ -1,74 +0,86 @@ | ||
var isBuiltIn = (function () { | ||
var built_ins = [ | ||
Object, | ||
Function, | ||
Array, | ||
String, | ||
Boolean, | ||
Number, | ||
Date, | ||
RegExp, | ||
Error | ||
]; | ||
var built_ins_length = built_ins.length; | ||
return function (_constructor) { | ||
for (var i = 0; i < built_ins_length; i++) { | ||
if (built_ins[i] === _constructor) { | ||
return true; | ||
(function (factory) { | ||
if (typeof exports == 'object') { | ||
module.exports = factory(); | ||
} else if ((typeof define == 'function') && define.amd) { | ||
define(factory); | ||
} | ||
}(function () { | ||
var isBuiltIn = (function () { | ||
var built_ins = [ | ||
Object, | ||
Function, | ||
Array, | ||
String, | ||
Boolean, | ||
Number, | ||
Date, | ||
RegExp, | ||
Error | ||
]; | ||
var built_ins_length = built_ins.length; | ||
return function (_constructor) { | ||
for (var i = 0; i < built_ins_length; i++) { | ||
if (built_ins[i] === _constructor) { | ||
return true; | ||
} | ||
} | ||
} | ||
return false; | ||
}; | ||
})(); | ||
return false; | ||
}; | ||
})(); | ||
var stringType = (function () { | ||
var _toString = ({}).toString; | ||
return function (obj) { | ||
// [object Blah] -> Blah | ||
var stype = _toString.call(obj).slice(8, -1); | ||
var stringType = (function () { | ||
var _toString = ({}).toString; | ||
return function (obj) { | ||
// [object Blah] -> Blah | ||
var stype = _toString.call(obj).slice(8, -1); | ||
if ((obj === null) || (obj === undefined)) { | ||
return stype.toLowerCase(); | ||
} | ||
var ctype = of(obj); | ||
if (ctype && !isBuiltIn(ctype)) { | ||
return ctype.name; | ||
} else { | ||
return stype; | ||
} | ||
}; | ||
})(); | ||
function of (obj) { | ||
if ((obj === null) || (obj === undefined)) { | ||
return stype.toLowerCase(); | ||
} | ||
var ctype = of(obj); | ||
if (ctype && !isBuiltIn(ctype)) { | ||
return ctype.name; | ||
return obj; | ||
} else { | ||
return stype; | ||
return obj.constructor; | ||
} | ||
}; | ||
})(); | ||
function of (obj) { | ||
if ((obj === null) || (obj === undefined)) { | ||
return obj; | ||
} else { | ||
return obj.constructor; | ||
function is (obj, test) { | ||
var typer = (of(test) === String) ? stringType : of; | ||
return (typer(obj) === test); | ||
}; | ||
function instance (obj, test) { | ||
return (obj instanceof test); | ||
} | ||
}; | ||
function is (obj, test) { | ||
var typer = (of(test) === String) ? stringType : of; | ||
return (typer(obj) === test); | ||
}; | ||
var exports = function (obj, type) { | ||
if (arguments.length == 1) { | ||
return of(obj); | ||
} else { | ||
return is(obj, type); | ||
} | ||
} | ||
function instance (obj, test) { | ||
return (obj instanceof test); | ||
} | ||
exports.instance = instance; | ||
exports.string = stringType; | ||
exports.of = of; | ||
exports.is = is; | ||
module.exports = function (obj, type) { | ||
if (arguments.length == 1) { | ||
return of(obj); | ||
} else { | ||
return is(obj, type); | ||
} | ||
} | ||
return exports; | ||
module.exports.instance = instance; | ||
module.exports.string = stringType; | ||
module.exports.of = of; | ||
module.exports.is = is; | ||
})); |
{ | ||
"name": "type-of-is", | ||
"version": "3.1.2", | ||
"version": "3.1.3", | ||
"description": "Determine and test types using constructor or {}.toString", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -43,3 +43,3 @@ # Description | ||
3.1.2 | ||
3.1.3 | ||
@@ -46,0 +46,0 @@ |
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
19931
272