Comparing version 8.3.1 to 8.3.2
@@ -5,2 +5,5 @@ const format = require("../helpers/format"); | ||
// Regexes. | ||
const R_STARTS_WITH_FUNCTION = /^[a-zA-Z0-9-_.]+\(\): /; | ||
/** | ||
@@ -36,6 +39,9 @@ * ValueError | ||
// Prepend the calling function name to the prefix, e.g. "name" → "MyClass.myFunc(): name" | ||
if (!prefix) prefix = frame.function; | ||
else if (prefix.indexOf(": ") === -1) | ||
// Skip any prefixes that already have a ':' colon. | ||
if (!prefix) { | ||
// No prefix (just use function name). | ||
prefix = frame.function; | ||
} else if (!R_STARTS_WITH_FUNCTION.test(prefix)) { | ||
// Skip any prefixes that already have a ':' colon by matching the regexp. | ||
prefix = `${frame.function}: ${prefix}`; | ||
} | ||
} | ||
@@ -42,0 +48,0 @@ // Update file, line, column. |
{ | ||
"name": "blork", | ||
"description": "Blork! Mini runtime type checking in Javascript", | ||
"version": "8.3.1", | ||
"version": "8.3.2", | ||
"license": "0BSD", | ||
@@ -6,0 +6,0 @@ "author": "Dave Houlbrooke <dave@shax.com>", |
@@ -85,3 +85,3 @@ const { ValueError, EMPTY } = require("../../lib/exports"); | ||
}); | ||
test("Return correct error with reason, value, and prefix (named function but with prefix including ': ' colon space)", () => { | ||
test("Return correct error with reason, value, and prefix (named function with prefix including 'myFunc(): ' etc at the start)", () => { | ||
function abc() { | ||
@@ -88,0 +88,0 @@ const e = new ValueError("Reason", 123, "myFunc(): Prefix"); |
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
211176
3877