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

types.js

Package Overview
Dependencies
Maintainers
1
Versions
48
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

types.js - npm Package Compare versions

Comparing version 1.2.4 to 1.2.5

.fuse_hidden0000002500000001

2

package.json
{
"name": "types.js",
"version": "1.2.4",
"version": "1.2.5",
"description": "A tiny Javascript type-check library",

@@ -5,0 +5,0 @@ "main": "types.min.js",

@@ -8,15 +8,14 @@ types.js

Because type checking in Javascript is so confusing and contradictory sometimes, I decided to make a
definitive library for myself, with for me understandable standards.
definitive library for myself, with for me understandable/useful standards.
Standard Javascript `(NaN !== NaN) == true` still freakes me out, I just don't like to see that kind of stuff in
my code. With types.js I can now test NaN with: `Types.isNaN(NaN)` or `Types.typeof( parseInt('Not A Number!') ) === 'nan'`,
both will return true.
Standard Javascript `(NaN !== NaN) == true` still freakes me out, I just don't like it. With types.js I can now
test NaN with: `Types.isNaN(NaN)` or `Types.typeof( parseInt('Not A Number!') ) === 'nan'`, both will return true.
Object is another one; `typeof ['array']` renders `'object'`, even in strict mode. So if we want to know
if some input is an `'object'`, we are constantly fooled by `typeof` returning `'object'` for `[]`, `null`
and `/regexp/`. With types.js the latter returns `'array'`, `'null'` and `'regexp'` respectively.
Object is another one; `typeof ['array']` renders `'object'` in standard JS. So if we want to know if some input
is a 'real Object', we are constantly fooled by `typeof` returning `'object'` for `[]`, `null` and `/regexp/`.
With types.js the latter returns `'array'`, `'null'` and `'regexp'` respectively.
Be careful with using types.js for variables created with `new Number()` or other non-literal instantiations. No
support for them, because I don't want to get `'number'` on `Types.typeof( new Number(10) )`, as it actually is an object
where you can add stuff to.
support for them, because I don't want to get `'number'` on `Types.typeof( new Number(10) )`, as it actually is an
object where you can add stuff to.

@@ -23,0 +22,0 @@ I've added support for multiple arguments so we can test for multiple values in one call. For save variable

@@ -94,9 +94,9 @@ // Generated by CoffeeScript 1.8.0

'Array': function(value) {
return value instanceof Array;
return (typeof value === 'object') && (value instanceof Array);
},
'RegExp': function(value) {
return value instanceof RegExp;
return (typeof value === 'object') && (value instanceof RegExp);
},
'Date': function(value) {
return value instanceof Date;
return (typeof value === 'object') && (value instanceof Date);
},

@@ -103,0 +103,0 @@ 'Object': function(value) {

@@ -1,1 +0,1 @@

(function(){"use strict";var n,r,t,e,u,i;n={parseIntBase:10};e={Boolean:false,String:"",Number:0,Object:{},Array:[],Function:function(){}};t=function(r){var t;t=function(t){switch(r){case"Number":if(n.notNaN(t=parseInt(t,n.parseIntBase))){return t}break;case"String":if(n.isStringOrNumber(t)){return t+""}break;default:if(n["typeof"](t)===r.toLowerCase()){return t}}return false};return function(u,i){if(i==null){i=u}if(n["is"+r](u)){return u}if(false!==(i=t(i))){return i}return e[r]}};u=function(n,r,t){var e,u,o;if(t==null){t=[]}if(t.length<1){if(n===i.Undefined){return true}return false}for(u=0,o=t.length;u<o;u++){e=t[u];if(n(e)===r){return r}}return!r};i={Undefined:function(n){return n===void 0},Null:function(n){return n===null},Boolean:function(n){return typeof n==="boolean"},String:function(n){return typeof n==="string"},Function:function(n){return typeof n==="function"},Number:function(n){return typeof n==="number"&&n===n},Array:function(n){return n instanceof Array},RegExp:function(n){return n instanceof RegExp},Date:function(n){return n instanceof Date},Object:function(n){return typeof n==="object"&&!(n instanceof Array)&&!(n instanceof RegExp)&&!(n instanceof Date)&&!(n===null)},NaN:function(n){return typeof n==="number"&&n!==n}};i.StringOrNumber=function(n){return i["String"](n)||i["Number"](n)};r=true;(function(){var o,f,a;a=[];for(o in i){f=i[o];a.push(function(i,o){n["is"+i]=o;n["not"+i]=function(n){return!o(n)};n["has"+i]=function(){return u(o,r,arguments)};n["all"+i]=function(){return u(o,!r,arguments)};if(i in e){return n["force"+i]=t(i)}}(o,f))}return a})();n["typeof"]=function(n){var r,t;for(t in i){r=i[t];if(r(n)===true){return t.toLowerCase()}}return"unknown"};if(typeof window!=="undefined"&&window!==null){window.Types=n}else if(module){module.exports=n}}).call(this);
(function(){"use strict";var n,t,r,e,u,o;n={parseIntBase:10},e={Boolean:!1,String:"",Number:0,Object:{},Array:[],Function:function(){}},r=function(t){var r;return r=function(r){switch(t){case"Number":if(n.notNaN(r=parseInt(r,n.parseIntBase)))return r;break;case"String":if(n.isStringOrNumber(r))return r+"";break;default:if(n["typeof"](r)===t.toLowerCase())return r}return!1},function(u,o){return null==o&&(o=u),n["is"+t](u)?u:!1!==(o=r(o))?o:e[t]}},u=function(n,t,r){var e,u,i;if(null==r&&(r=[]),r.length<1)return n===o.Undefined?!0:!1;for(u=0,i=r.length;i>u;u++)if(e=r[u],n(e)===t)return t;return!t},o={Undefined:function(n){return void 0===n},Null:function(n){return null===n},Boolean:function(n){return"boolean"==typeof n},String:function(n){return"string"==typeof n},Function:function(n){return"function"==typeof n},Number:function(n){return"number"==typeof n&&n===n},Array:function(n){return"object"==typeof n&&n instanceof Array},RegExp:function(n){return"object"==typeof n&&n instanceof RegExp},Date:function(n){return"object"==typeof n&&n instanceof Date},Object:function(n){return!("object"!=typeof n||n instanceof Array||n instanceof RegExp||n instanceof Date||null===n)},NaN:function(n){return"number"==typeof n&&n!==n}},o.StringOrNumber=function(n){return o.String(n)||o.Number(n)},t=!0,function(){var i,f,c;c=[];for(i in o)f=o[i],c.push(function(o,i){return n["is"+o]=i,n["not"+o]=function(n){return!i(n)},n["has"+o]=function(){return u(i,t,arguments)},n["all"+o]=function(){return u(i,!t,arguments)},o in e?n["force"+o]=r(o):void 0}(i,f));return c}(),n["typeof"]=function(n){var t,r;for(r in o)if(t=o[r],t(n)===!0)return r.toLowerCase();return"unknown"},"undefined"!=typeof window&&null!==window?window.Types=n:module&&(module.exports=n)}).call(this);

Sorry, the diff of this file is not supported yet

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