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

hadron-type-checker

Package Overview
Dependencies
Maintainers
1
Versions
497
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hadron-type-checker - npm Package Compare versions

Comparing version 0.1.0 to 0.2.0

21

lib/type-checker.js

@@ -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",

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