Comparing version 8.3.2 to 8.3.3
@@ -16,2 +16,22 @@ const debug = require("../helpers/debug"); | ||
module.exports = [ | ||
// Return type. | ||
// Changes error message from e.g. "Must be string" to "Must return string" | ||
{ | ||
start: "return ", | ||
callback(type, find) { | ||
// Get normal checker. | ||
const valueChecker = find(type); | ||
// Create a checker. | ||
const checker = v => valueChecker(v); | ||
// Checker settings. | ||
checker.desc = valueChecker.desc; | ||
checker.prefix = "Must return"; | ||
// Return it. | ||
return checker; | ||
} | ||
}, | ||
// AND combined type, e.g. `upper & str` | ||
@@ -434,23 +454,3 @@ { | ||
} | ||
}, | ||
// Return type. | ||
// Changes error message from e.g. "Must be string" to "Must return string" | ||
{ | ||
start: "return ", | ||
callback(type, find) { | ||
// Get normal checker. | ||
const valueChecker = find(type); | ||
// Create a checker. | ||
const checker = v => valueChecker(v); | ||
// Checker settings. | ||
checker.desc = valueChecker.desc; | ||
checker.prefix = "Must return"; | ||
// Return it. | ||
return checker; | ||
} | ||
} | ||
]; |
{ | ||
"name": "blork", | ||
"description": "Blork! Mini runtime type checking in Javascript", | ||
"version": "8.3.2", | ||
"version": "8.3.3", | ||
"license": "0BSD", | ||
@@ -6,0 +6,0 @@ "author": "Dave Houlbrooke <dave@shax.com>", |
@@ -455,3 +455,6 @@ const BlorkError = require("../../lib/errors/BlorkError"); | ||
}); | ||
test("Return type has highest precedence", () => { | ||
expect(() => check(123, "return str+ | boolean")).toThrow(/Must return \(non-empty string\) or boolean/); | ||
}); | ||
}); | ||
}); |
211344
3880