hadron-type-checker
Advanced tools
Comparing version 0.1.0 to 0.2.0
@@ -35,3 +35,3 @@ 'use strict'; | ||
function toDate(object) { | ||
return new Date(object); | ||
return Date.parse(object); | ||
} | ||
@@ -93,4 +93,4 @@ | ||
class Test { | ||
constructor(regex, types) { | ||
this.regex = regex; | ||
constructor(tester, types) { | ||
this.tester = tester; | ||
this.types = types; | ||
@@ -100,2 +100,9 @@ } | ||
class DateCheck { | ||
test(string) { | ||
var date = Date.parse(string) | ||
return date ? true : false; | ||
} | ||
} | ||
/** | ||
@@ -105,3 +112,3 @@ * The various string tests. | ||
const STRING_TESTS = [ | ||
new Test(/^$/, [ 'String', 'MinKey', 'MaxKey', 'Object', 'Array' ]), | ||
new Test(/^$/, [ 'String', 'Null', 'Undefined', 'MinKey', 'MaxKey', 'Object', 'Array' ]), | ||
new Test(/^-?\d+$/, [ 'String', 'Number', 'Object', 'Array' ]), | ||
@@ -111,3 +118,5 @@ new Test(/^-?(\d*\.)?\d+$/, [ 'String', 'Number', 'Object', 'Array' ]), | ||
new Test(/^(undefined)$/, [ 'String', 'Undefined', 'Object', 'Array' ]), | ||
new Test(/^(true|false)$/, [ 'String', 'Boolean', 'Object', 'Array' ]) | ||
new Test(/^(true|false)$/, [ 'String', 'Boolean', 'Object', 'Array' ]), | ||
new Test(/^\/(.*)\/$/, [ 'String', 'BSONRegExp', 'Object', 'Array' ]), | ||
new Test(new DateCheck(), [ 'String', 'Date', 'Object', 'Array' ]) | ||
]; | ||
@@ -174,3 +183,3 @@ | ||
var passing = find(STRING_TESTS, (test) => { | ||
return test.regex.test(string); | ||
return test.tester.test(string); | ||
}); | ||
@@ -177,0 +186,0 @@ return passing ? passing.types : [ 'String', 'Object', 'Array' ]; |
@@ -7,3 +7,3 @@ { | ||
"homepage": "https://github.com/mongodb-js/hadron-type-checker", | ||
"version": "0.1.0", | ||
"version": "0.2.0", | ||
"repository": { | ||
@@ -10,0 +10,0 @@ "type": "git", |
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
16121
163
171