Comparing version 5.0.0 to 5.0.1
@@ -424,5 +424,6 @@ // @flow | ||
// Check that we actually need to do this loop by comparing the lengths. | ||
if (valueKeys.length > typeKeys.length) { | ||
// -1 subtracts the _any key itself. | ||
if (valueKeys.length > typeKeys.length - 1) { | ||
// Make a list of the excess keys (that are in valueKeys but not in typeKeys). | ||
const excessKeys = valueKeys.filter(v => typeKeys.indexOf(v) === -1); | ||
const excessKeys = valueKeys.filter(v => !~typeKeys.indexOf(v)); | ||
@@ -429,0 +430,0 @@ // Loop through all excess keys and check against the ANY key. |
{ | ||
"name": "blork", | ||
"description": "Blork! Mini runtime type checking in Javascript", | ||
"version": "5.0.0", | ||
"version": "5.0.1", | ||
"license": "0BSD", | ||
@@ -6,0 +6,0 @@ "author": "Dave Houlbrooke <dave@shax.com>", |
@@ -38,2 +38,3 @@ const BlorkError = require("../lib/errors/BlorkError"); | ||
expect(check({ a: 1, b: 2, c: undefined }, { a: "num", _any: "num?" })).toBe(undefined); | ||
expect(check({ a: new Map(), b: new Map(), c: new Map() }, { _any: Map })).toBe(undefined); | ||
}); | ||
@@ -48,2 +49,5 @@ test("Object literal types with _any property pass correctly when _any isn't used", () => { | ||
expect(() => check({ a: 1, b: 2, c: "c" }, { a: "num", _any: "num" })).toThrow(TypeError); | ||
expect(() => check({ a: 1 }, { _any: "str" })).toThrow(TypeError); | ||
expect(() => check({ a: new Map() }, { _any: Set })).toThrow(TypeError); | ||
expect(() => check({ a: new Map(), b: new Set(), c: new Set() }, { _any: Set })).toThrow(TypeError); | ||
}); | ||
@@ -50,0 +54,0 @@ test("Deep object literal types with _any property pass correctly", () => { |
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
114171
1933