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

of-type

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

of-type - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

testing.js

8

index.js

@@ -8,3 +8,3 @@ module.exports = function(val,type){

}
var reg = /\[object Arguments\]/i;
if(isTypeString){

@@ -18,4 +18,3 @@ var t = type.toLowerCase().split('|');

if(val===null||val===undefined) return false;
if((/arguments/i).test(val.toString())&&t.some((i)=>i==='arguments')) return true;
if((/arguments/i).test(val.toString())&&t.some((i)=>i==='object')) return false;
if((reg).test(val.toString())&&t.some((i)=>i==='arguments')) return true;
return t.some((i)=>i===val.constructor.name.toLowerCase());

@@ -31,6 +30,5 @@ }

if(val===null||val===undefined) return false;
if(type.test('arguments')&&(/arguments/i).test(val.toString())) return true;
if(type.test('object')&&(/arguments/i).test(val.toString())) return false;
if(type.test('arguments')&&(reg).test(val.toString())) return true;
return type.test(val.constructor.name);
}
};
{
"name": "of-type",
"version": "1.0.0",
"version": "1.0.1",
"description": "Check if the given value is of the particular type or types.",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -35,3 +35,3 @@ # Description

* The **`types`** can contain the value: `'falsy'`. It returns `true` for the **`val`** values like: `""`, `false`, `0`, `null`, `undefined`, etc.
* The **`types`** can contain the value: `''` or `'any'`, then the **`val`** can be of **any type**
* The **`types`** can contain the value: `''` or `'any'`, then it returns `true` for the **`val`** of **any type**

@@ -56,4 +56,4 @@ #### Return value

ofType(function(){},'function'); //true
ofType(function(){return arguments;},'arguments'); //true
ofType(function(){return arguments;},'object'); //false
ofType((function(){return arguments;})(),'arguments'); //true
ofType((function(){return arguments;})(),'object'); //true
ofType(()=>{},'FuNcTiOn'); //true

@@ -77,3 +77,3 @@ ofType(ofType,'function'); //true

ofType(10,'any|string'); //
ofType(10,'any|string'); //true
ofType(10,''); //true

@@ -108,4 +108,6 @@

ofType(!0,/Boolean/); //true
ofType(function(){return arguments;},/arguments/); //true
ofType((function(){return arguments;})(),/arguments/); //true
ofType((function(){return arguments;})(),/object/i); //true
ofType(123,/any/i); //true

@@ -112,0 +114,0 @@ ofType("123",/any/i); //true

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