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

type-of-is

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

type-of-is - npm Package Compare versions

Comparing version 3.1.3 to 3.2.0

10

example.js

@@ -83,2 +83,10 @@ var Type = require('./');

var t = new Type.of(s)("t");
console.log(t); // "t"
console.log(t.toUpperCase()); // "T"
// Type.any(obj, [Array, Of, Types]) and Type(obj, [Array, Of, Types]) should test whether
// the object is any of the passed in types
var str = 'hihihi';
console.log(Type.any(str, [String, Number, Array])); // true
console.log(Type(str, [Array, RegExp])); // false

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

(function (factory) {
(function (factory) {
if (typeof exports == 'object') {

@@ -60,3 +60,3 @@ module.exports = factory();

}
};
}

@@ -66,4 +66,4 @@ function is (obj, test) {

return (typer(obj) === test);
};
}
function instance (obj, test) {

@@ -73,2 +73,15 @@ return (obj instanceof test);

function any (obj, tests) {
if (!is(tests, Array)) {
throw ("Second argument to .any() should be array")
}
for (var i = 0; i < tests.length; i++) {
var test = tests[i];
if (is(obj, test)) {
return true;
}
}
return false;
}
var exports = function (obj, type) {

@@ -78,3 +91,7 @@ if (arguments.length == 1) {

} else {
return is(obj, type);
if (is(type, Array)) {
return any(obj, type);
} else {
return is(obj, type);
}
}

@@ -87,2 +104,3 @@ }

exports.is = is;
exports.any = any;

@@ -89,0 +107,0 @@ return exports;

2

package.json
{
"name": "type-of-is",
"version": "3.1.3",
"version": "3.2.0",
"description": "Determine and test types using constructor or {}.toString",

@@ -5,0 +5,0 @@ "license": "MIT",

@@ -43,3 +43,3 @@ # Description

3.1.3
3.2.0

@@ -59,3 +59,3 @@

"dependencies": {
"type-of-is": "3.1.x"
"type-of-is": "3.2.x"
}

@@ -168,4 +168,9 @@ }

var t = new Type.of(s)("t");
console.log(t); // "t"
console.log(t.toUpperCase()); // "T"
// Type.any(obj, [Array, Of, Types]) and Type(obj, [Array, Of, Types]) should test whether
// the object is any of the passed in types
var str = 'hihihi';
console.log(Type.any(str, [String, Number, Array])); // true
console.log(Type(str, [Array, RegExp])); // false

@@ -172,0 +177,0 @@ // multi-frame dom

@@ -131,3 +131,15 @@ var Path = require('path');

Assert(!Type.instance(ralph, String));
},
"Type.any and Type(obj, <Array>) should check whether an array is one of many types": function () {
var str = 'abcdefg';
Assert(Type.any(str, [String]));
Assert(Type.any(str, [Array, String]));
Assert(!Type.any(str, [Array, Number]));
Assert(Type(str, [String]));
Assert(!Type(str, [Array, Number]));
Assert.throws(function () {
Type.any(str, String);
}, /should be array/);
}
});

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