Comparing version 1.15.1 to 1.16.0
15
index.js
@@ -233,17 +233,2 @@ 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 | ||
@@ -250,0 +235,0 @@ typeforce.TfTypeError = TfTypeError |
{ | ||
"name": "typeforce", | ||
"version": "1.15.1", | ||
"version": "1.16.0", | ||
"description": "Another biased type checking solution for Javascript", | ||
@@ -21,6 +21,8 @@ "keywords": [ | ||
"files": [ | ||
"async.js", | ||
"errors.js", | ||
"extra.js", | ||
"index.js", | ||
"native.js" | ||
"native.js", | ||
"nothrow.js" | ||
], | ||
@@ -27,0 +29,0 @@ "repository": { |
@@ -117,2 +117,27 @@ # typeforce | ||
**Pro**tips (no throw) | ||
``` javascript | ||
var typeforce = require('typeforce/nothrow') | ||
var value = 'foobar' | ||
if (typeforce(typeforce.Number, value)) { | ||
// didn't throw! | ||
console.log(`${value} is a number`) // never happens | ||
} else { | ||
console.log(`Oops, ${typeforce.error.message}`) | ||
// prints 'Oops, Expected Number, got String foobar' | ||
} | ||
``` | ||
**Pro**tips (async) | ||
``` | ||
var typeforce = require('typeforce/async') | ||
typeforce(typeforce.Number, value, function (err) { | ||
if (err) return console.log(`Oops, ${typeforce.error.message}`) | ||
console.log(`${value} is a number`) // never happens | ||
}) | ||
``` | ||
**WARNING**: Be very wary of using the `quacksLike` type, as it relies on the `Foo.name` property. | ||
@@ -119,0 +144,0 @@ If that property is mangled by a transpiler, such as `uglifyjs`, you will have a bad time. |
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
18302
9
391
146