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

oftype

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

oftype - npm Package Compare versions

Comparing version 0.1.1 to 0.1.2

test/oftype-test4.js

22

oftype.js

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

function oftype(val, type) {
function oftype(val, type, options) {
nullAsObject = oftype.nullAsObject;
primitiveObject = oftype.primitiveObject;
if (options && (options.nullAsObject !== undefined)) {
nullAsObject = options.nullAsObject;
}
if (options && (options.primitiveObject !== undefined)) {
primitive = options.primitiveObject;
}
if (type === undefined || val === undefined) {

@@ -7,6 +19,6 @@ return type === val;

return type === null ||
oftype.nullAsObject && type === Object;
nullAsObject && type === Object;
} else if (type === Number) {
if (oftype.primitiveObject) {
if (primitiveObject) {
return toString.call(val) === '[object Number]';

@@ -18,3 +30,3 @@ }

} else if (type === String) {
if (oftype.primitiveObject) {
if (primitiveObject) {
return toString.call(val) === '[object String]';

@@ -26,3 +38,3 @@ }

} else if (type === Boolean) {
if (oftype.primitiveObject) {
if (primitiveObject) {
return toString.call(val) === '[object Boolean]';

@@ -29,0 +41,0 @@ }

{
"name": "oftype",
"version": "0.1.1",
"version": "0.1.2",
"description": "A JavaScript module for checking variable runtime type",

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

@@ -64,2 +64,7 @@ oftype

Alternatively, to avoid setting the options in every function call, the options could also be set globally:
```javascript
oftype.nullAsObject = true;
oftype.primitiveObject = true;
```
## Test

@@ -66,0 +71,0 @@ Make sure `mocha` is installed globally

@@ -57,2 +57,3 @@ var oftype = require('../oftype');

oftype.primitiveObject = true;
oftype.nullAsObject = false;
},

@@ -59,0 +60,0 @@

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