Comparing version 1.4.3 to 1.4.4
{ | ||
"name": "types.js", | ||
"version": "1.4.3", | ||
"version": "1.4.4", | ||
"description": "A tiny (1.8kb), essential Javascript type-check library", | ||
@@ -5,0 +5,0 @@ "main": "types.min.js", |
types.js | ||
======== | ||
<br/> | ||
A tiny(1.8Kb), essential Javascript type checking library. | ||
___ | ||
types.js has moved!!! | ||
===================== | ||
**types.js is now types-js** | ||
<br/> | ||
<br/> | ||
Check types-js for the latest version. I had to move this because for some reason the npm search engine cannot find types.js, most | ||
of the time.. | ||
<br/> | ||
<br/> | ||
___ | ||
A tiny(1.9Kb), essential Javascript type checking library. | ||
@@ -21,4 +10,4 @@ - fixes NaN, array, null, etc.. | ||
- can force a value to be of some type, with optional value if conversion is not possible | ||
___ | ||
**A few quick examples:** | ||
@@ -67,3 +56,19 @@ ```javascript | ||
___ | ||
**node.js** | ||
For use with node.js you can install with `npm install types.js` | ||
**AMD** | ||
When using AMD, you can load types.js like so: | ||
```javascript | ||
require.config({ | ||
paths: { | ||
'types', [ '../path/to/types.min' ] | ||
} | ||
}); | ||
require( ['types'], function( Types ){ | ||
console.log( Types.isNumber(0) ); | ||
// true | ||
}); | ||
``` | ||
___ | ||
@@ -247,3 +252,3 @@ | ||
// now func will again become equal to showAuthor because forceFunction will | ||
// return showAuthor, as replacement is the only valid function found: | ||
// return showAuthor as replacement is the only valid function found: | ||
var func= _.forceFunction( brokenFunc, showAuthor ); | ||
@@ -261,7 +266,7 @@ console.log( func === showAuthor ); | ||
// a callable function you can safely call in one go like this: | ||
_.forceFunction( showAuthor )( 'Dennis Raymondo' ); | ||
// Author: Dennis Raymondo | ||
_.forceFunction( brokenFunc, showAuthor )( 'Dennis' ); | ||
// Author: Dennis | ||
// now we call with two invalid functions: | ||
_.forceFunction( brokenFunc, brokenFunc )( 'Dennis Raymondo' ); | ||
_.forceFunction( brokenFunc, brokenFunc )( 'Dennis' ); | ||
// | ||
@@ -368,3 +373,10 @@ // the empty dummy-function was called, no crash | ||
========== | ||
**1.4.4** | ||
Added AMD support, you can now: | ||
```javascript | ||
require ['types'], ( Types ) -> | ||
``` | ||
with require.js for example. | ||
___ | ||
**1.4.2** | ||
@@ -384,3 +396,3 @@ | ||
__________________________________________ | ||
___ | ||
**1.3.5** | ||
@@ -387,0 +399,0 @@ |
@@ -93,3 +93,3 @@ // Generated by CoffeeScript 1.8.0 | ||
default: | ||
if (_['is' + type](value)) { | ||
if (Types['is' + type](value)) { | ||
return value; | ||
@@ -163,2 +163,8 @@ } | ||
if (('function' === typeof define) && define.amd) { | ||
define('types', [], function() { | ||
return Types; | ||
}); | ||
} | ||
if (typeof window !== 'undefined') { | ||
@@ -165,0 +171,0 @@ window.Types = Types; |
@@ -1,1 +0,1 @@ | ||
(function(){"use strict";var n,r,t,e,u,i,o,f,c;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)},t=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(c["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,t,e){var u,i,o;if(null==e&&(e=[]),e.length<1)return n===r.Undefined;for(i=0,o=e.length;o>i;i++)if(u=e[i],n(u)===t)return t;return!t},e=!0,function(){var i,f,c;c=[];for(i in r)f=r[i],c.push(function(r,i){return t["is"+r]=i,t["not"+r]=function(n){return!i(n)},t["has"+r]=function(){return o(i,e,arguments)},t["all"+r]=function(){return o(i,!e,arguments)},r in n?t["force"+r]=u(r):void 0}(i,f));return c}(),t["typeof"]=function(n){var t,e;for(t in r)if(e=r[t],e(n)===!0)return t.toLowerCase()},"undefined"!=typeof window?window.Types=t:"undefined"!=typeof module&&(module.exports=t)}).call(this); | ||
(function(){"use strict";var n,r,e,t,u,i,o,f,c;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["typeof"]=function(n){var e,t;for(e in r)if(t=r[e],t(n)===!0)return e.toLowerCase()},"function"==typeof define&&define.amd&&define("types",[],function(){return e}),"undefined"!=typeof window?window.Types=e:"undefined"!=typeof module&&(module.exports=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
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
152695
2027
438