bson-type-of-is
Advanced tools
Comparing version 1.2.0 to 1.3.0
21
index.js
@@ -47,3 +47,3 @@ // BSON types | ||
var types = [ | ||
var typesArray = [ | ||
{ | ||
@@ -120,8 +120,13 @@ alias: 'undefined', | ||
var typesObject = typesArray.reduce(function (acc, type) { | ||
acc[type.alias] = type.check | ||
return acc | ||
}, {}); | ||
// recognize bson types | ||
function bsonTypeOfIs (value) { | ||
var i | ||
for (i = 0; i < types.length; i++) { | ||
if (types[i].check(value)) { | ||
return types[i].alias | ||
for (i = 0; i < typesArray.length; i++) { | ||
if (typesArray[i].check(value)) { | ||
return typesArray[i].alias | ||
} | ||
@@ -137,3 +142,3 @@ } | ||
function testBsonType (type, value) { | ||
if (!types[type]) { | ||
if (!typesObject[type]) { | ||
throw { | ||
@@ -145,8 +150,10 @@ message: 'This type is not a bson type alias', | ||
return types[type].check(value) | ||
return typesObject[type].check(value) | ||
} | ||
bsonTypeOfIs.TYPES = TYPES | ||
bsonTypeOfIs.typesArray = typesArray | ||
bsonTypeOfIs.typesObject = typesObject | ||
bsonTypeOfIs.testBsonType = testBsonType | ||
bsonTypeOfIs.TYPES = TYPES | ||
module.exports = bsonTypeOfIs |
{ | ||
"name": "bson-type-of-is", | ||
"version": "1.2.0", | ||
"version": "1.3.0", | ||
"description": "Get BSON type alias of a value", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
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
4823
147