Comparing version 0.1.1 to 0.1.2
@@ -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 @@ |
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
8369
11
158
78