Comparing version 1.9.4 to 1.10.0
@@ -27,3 +27,3 @@ var errors = require('./errors') | ||
function HexN (length) { | ||
function _HexN (length) { | ||
return function HexN (value) { | ||
@@ -36,2 +36,5 @@ return Hex(value) && value.length === length | ||
function Finite (value) { | ||
return typeof value === 'number' && isFinite(value) | ||
} | ||
function Int8 (value) { return ((value << 24) >> 24) === value } | ||
@@ -53,4 +56,5 @@ function Int16 (value) { return ((value << 16) >> 16) === value } | ||
BufferN: _BufferN, | ||
Finite: Finite, | ||
Hex: Hex, | ||
HexN: HexN, | ||
HexN: _HexN, | ||
Int8: Int8, | ||
@@ -57,0 +61,0 @@ Int16: Int16, |
15
index.js
@@ -214,2 +214,17 @@ var errors = require('./errors') | ||
// async wrapper | ||
function __async (type, value, strict, callback) { | ||
// default to falsy strict if using shorthand overload | ||
if (typeof strict === 'function') return __async(type, value, false, strict) | ||
try { | ||
typeforce(type, value, strict) | ||
} catch (e) { | ||
return callback(e) | ||
} | ||
callback() | ||
} | ||
typeforce.async = __async | ||
typeforce.compile = compile | ||
@@ -216,0 +231,0 @@ typeforce.TfTypeError = TfTypeError |
{ | ||
"name": "typeforce", | ||
"version": "1.9.4", | ||
"version": "1.10.0", | ||
"description": "Another biased type checking solution for Javascript", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -14,13 +14,13 @@ var tape = require('tape') | ||
tape('passes ' + typeDescription + ' with ' + valueDescription, function (t) { | ||
t.plan(1) | ||
t.doesNotThrow(function () { | ||
typeforce(type, value, f.strict) | ||
}) | ||
t.plan(2) | ||
t.doesNotThrow(function () { typeforce(type, value, f.strict) }) | ||
typeforce.async(type, value, f.strict, t.ifErr) | ||
}) | ||
tape('passes ' + typeDescription + ' (compiled) with ' + valueDescription, function (t) { | ||
t.plan(1) | ||
t.doesNotThrow(function () { | ||
typeforce(typeforce.compile(type), value, f.strict) | ||
}) | ||
var compiled = typeforce.compile(type) | ||
t.plan(2) | ||
t.doesNotThrow(function () { typeforce(compiled, value, f.strict) }) | ||
typeforce.async(compiled, value, f.strict, t.ifErr) | ||
}) | ||
@@ -27,0 +27,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
473275
21225