Comparing version 1.5.1 to 1.5.2
{ | ||
"name": "types.js", | ||
"version": "1.5.1", | ||
"version": "1.5.2", | ||
"description": "A tiny (~2kb) Javascript type checker/enforcer library", | ||
@@ -5,0 +5,0 @@ "main": "types.min.js", |
43
types.js
@@ -0,5 +1,6 @@ | ||
// Generated by CoffeeScript 1.9.1 | ||
(function() { | ||
"use strict"; | ||
var LITERALS, TYPES, Types, breakIfEqual, createForce, instanceOf, testValues, typeOf, _, | ||
__slice = [].slice; | ||
var LITERALS, TYPES, Types, _, breakIfEqual, createForce, instanceOf, testValues, typeOf, | ||
slice = [].slice; | ||
@@ -110,3 +111,3 @@ instanceOf = function(type, value) { | ||
testValues = function(predicate, breakState, values) { | ||
var value, _i, _len; | ||
var i, len, value; | ||
if (values == null) { | ||
@@ -118,4 +119,4 @@ values = []; | ||
} | ||
for (_i = 0, _len = values.length; _i < _len; _i++) { | ||
value = values[_i]; | ||
for (i = 0, len = values.length; i < len; i++) { | ||
value = values[i]; | ||
if (predicate(value) === breakState) { | ||
@@ -131,7 +132,7 @@ return breakState; | ||
(function() { | ||
var name, predicate, _results; | ||
_results = []; | ||
var name, predicate, results; | ||
results = []; | ||
for (name in TYPES) { | ||
predicate = TYPES[name]; | ||
_results.push((function(name, predicate) { | ||
results.push((function(name, predicate) { | ||
Types['is' + name] = predicate; | ||
@@ -148,7 +149,17 @@ Types['not' + name] = function(value) { | ||
if (name in LITERALS) { | ||
return Types['force' + name] = createForce(name); | ||
Types['force' + name] = createForce(name); | ||
} | ||
return Types['getFirst' + name] = function() { | ||
var i, len, value, values; | ||
values = 1 <= arguments.length ? slice.call(arguments, 0) : []; | ||
for (i = 0, len = values.length; i < len; i++) { | ||
value = values[i]; | ||
if (Types['is' + name](value)) { | ||
return value; | ||
} | ||
} | ||
}; | ||
})(name, predicate)); | ||
} | ||
return _results; | ||
return results; | ||
})(); | ||
@@ -158,3 +169,3 @@ | ||
var args; | ||
args = 1 <= arguments.length ? __slice.call(arguments, 0) : []; | ||
args = 1 <= arguments.length ? slice.call(arguments, 0) : []; | ||
if (args.length < 2) { | ||
@@ -184,8 +195,12 @@ if (_.isString(args[0])) { | ||
}); | ||
} else if (typeof window !== 'undefined') { | ||
window.Types = Types; | ||
} else if (typeof module !== 'undefined') { | ||
} | ||
if (typeof module !== 'undefined') { | ||
module.exports = Types; | ||
} | ||
if (typeof window !== 'undefined') { | ||
window.Types = Types; | ||
} | ||
}).call(this); |
@@ -1,1 +0,1 @@ | ||
(function(){"use strict";var n,r,e,t,u,i,o,f,c,a=[].slice;i=function(n,r){return r instanceof n},f=function(n,r){return null==r&&(r="object"),typeof n===r},n={Boolean:!1,String:"",Object:{},Array:[],Function:function(){},Number:function(){var n;return n=new Number,n["void"]=!0,n}()},r={Undefined:function(n){return void 0===n},Null:function(n){return null===n},Function:function(n){return f(n,"function")},Boolean:function(n){return f(n,"boolean")},String:function(n){return f(n,"string")},Array:function(n){return f(n)&&i(Array,n)},RegExp:function(n){return f(n)&&i(RegExp,n)},Date:function(n){return f(n)&&i(Date,n)},Number:function(n){return f(n,"number")&&n===n||f(n)&&i(Number,n)},Object:function(n){return!(!f(n)||null===n||i(Boolean,n)||i(Number,n)||i(Array,n)||i(RegExp,n)||i(Date,n))},NaN:function(n){return f(n,"number")&&n!==n},Defined:function(n){return void 0!==n}},r.StringOrNumber=function(n){return r.String(n)||r.Number(n)},e=c={parseIntBase:10},u=function(r){var t;return t=function(n){switch(r){case"Number":if(c.isNumber(n=parseInt(n,c.parseIntBase))&&!n["void"])return n;break;case"String":if(c.isStringOrNumber(n))return n+"";break;default:if(e["is"+r](n))return n}},function(e,u){return null!=e&&void 0!==(e=t(e))?e:null!=u&&void 0!==(u=t(u))?u:n[r]}},o=function(n,e,t){var u,i,o;if(null==t&&(t=[]),t.length<1)return n===r.Undefined;for(i=0,o=t.length;o>i;i++)if(u=t[i],n(u)===e)return e;return!e},t=!0,function(){var i,f,c;c=[];for(i in r)f=r[i],c.push(function(r,i){return e["is"+r]=i,e["not"+r]=function(n){return!i(n)},e["has"+r]=function(){return o(i,t,arguments)},e["all"+r]=function(){return o(i,!t,arguments)},r in n?e["force"+r]=u(r):void 0}(i,f));return c}(),e.intoArray=function(){var n;return n=1<=arguments.length?a.call(arguments,0):[],n.length<2&&(c.isString(n[0])?n=n.join("").replace(/^\s+|\s+$/g,"").replace(/\s+/g," ").split(" "):c.isArray(n[0])&&(n=n[0])),n},e["typeof"]=function(n){var e,t;for(e in r)if(t=r[e],t(n)===!0)return e.toLowerCase()},"undefined"!=typeof define&&null!==define&&"function"==typeof define&&define.amd?define("types",[],function(){return e}):"undefined"!=typeof window?window.Types=e:"undefined"!=typeof module&&(module.exports=e)}).call(this); | ||
(function(){"use strict";var n,r,e,t,u,i,o,f,c,a=[].slice;o=function(n,r){return r instanceof n},c=function(n,r){return null==r&&(r="object"),typeof n===r},n={Boolean:!1,String:"",Object:{},Array:[],Function:function(){},Number:function(){var n;return n=new Number,n["void"]=!0,n}()},r={Undefined:function(n){return void 0===n},Null:function(n){return null===n},Function:function(n){return c(n,"function")},Boolean:function(n){return c(n,"boolean")},String:function(n){return c(n,"string")},Array:function(n){return c(n)&&o(Array,n)},RegExp:function(n){return c(n)&&o(RegExp,n)},Date:function(n){return c(n)&&o(Date,n)},Number:function(n){return c(n,"number")&&n===n||c(n)&&o(Number,n)},Object:function(n){return!(!c(n)||null===n||o(Boolean,n)||o(Number,n)||o(Array,n)||o(RegExp,n)||o(Date,n))},NaN:function(n){return c(n,"number")&&n!==n},Defined:function(n){return void 0!==n}},r.StringOrNumber=function(n){return r.String(n)||r.Number(n)},e=t={parseIntBase:10},i=function(r){var u;return u=function(n){switch(r){case"Number":if(t.isNumber(n=parseInt(n,t.parseIntBase))&&!n["void"])return n;break;case"String":if(t.isStringOrNumber(n))return n+"";break;default:if(e["is"+r](n))return n}},function(e,t){return null!=e&&void 0!==(e=u(e))?e:null!=t&&void 0!==(t=u(t))?t:n[r]}},f=function(n,e,t){var u,i,o;if(null==t&&(t=[]),t.length<1)return n===r.Undefined;for(u=0,i=t.length;i>u;u++)if(o=t[u],n(o)===e)return e;return!e},u=!0,function(){var t,o,c;c=[];for(t in r)o=r[t],c.push(function(r,t){return e["is"+r]=t,e["not"+r]=function(n){return!t(n)},e["has"+r]=function(){return f(t,u,arguments)},e["all"+r]=function(){return f(t,!u,arguments)},r in n&&(e["force"+r]=i(r)),e["getFirst"+r]=function(){var n,t,u,i;for(i=1<=arguments.length?a.call(arguments,0):[],n=0,t=i.length;t>n;n++)if(u=i[n],e["is"+r](u))return u}}(t,o));return c}(),e.intoArray=function(){var n;return n=1<=arguments.length?a.call(arguments,0):[],n.length<2&&(t.isString(n[0])?n=n.join("").replace(/^\s+|\s+$/g,"").replace(/\s+/g," ").split(" "):t.isArray(n[0])&&(n=n[0])),n},e["typeof"]=function(n){var e,t;for(e in r)if(t=r[e],t(n)===!0)return e.toLowerCase()},"undefined"!=typeof define&&null!==define&&"function"==typeof define&&define.amd&&define("types",[],function(){return e}),"undefined"!=typeof module&&(module.exports=e),"undefined"!=typeof window&&(window.Types=e)}).call(this); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
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
64481
7
184
1