@brillout/libassert
Advanced tools
Comparing version 0.2.0 to 0.2.1
@@ -14,3 +14,3 @@ "use strict"; | ||
var sackLines__cleaned = stackLines | ||
.filter(function (line, i) { | ||
.filter(function (line) { | ||
// Remove stack traces related to this package | ||
@@ -20,6 +20,2 @@ if (isSelf(line)) { | ||
} | ||
// Remove the file that defines the assertion function from the stack trace | ||
if (isSelf(stackLines[i + 1])) { | ||
return false; | ||
} | ||
// Remove internal stack traces | ||
@@ -26,0 +22,0 @@ if (line.includes(" (internal/")) { |
{ | ||
"name": "@brillout/libassert", | ||
"version": "0.2.0", | ||
"version": "0.2.1", | ||
"description": "Assertions for library authors.", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -19,3 +19,6 @@ Minimalistic & simple assertions for library authors. | ||
const err = createError({ prefix: `[${libName}][Internal Error] Something unexpected happened, please open a GitHub issue.` }); | ||
const prefix = | ||
`[${libName}][Internal Error] Something unexpected happened, `+ | ||
`please open a GitHub issue.`; | ||
const err = createError({ prefix }); | ||
@@ -25,6 +28,3 @@ throw err; | ||
function assertUsage( | ||
condition: unknown, | ||
errorMessage: string | ||
): asserts condition { | ||
function assertUsage(condition: unknown, errorMessage: string): asserts condition { | ||
if (condition) { | ||
@@ -56,4 +56,8 @@ return; | ||
If your user calls `hello()` without arguments then `assertUsage` throws following error: | ||
The `createError(errorMessage)` is the same than `new Error(${prefix} ${errorMessage})` except that: | ||
- `prefix` and `errorMessage` are forbidden to contain new lines. | ||
- The stack trace is complete but also cleaned to remove useless information. | ||
If your user calls `hello(condition)` and `condition` is falsy then `assertUsage` throws following error: | ||
~~~ | ||
@@ -60,0 +64,0 @@ Error: [Awesome Library][Wrong Usage] Missing argument `name`. |
@@ -15,3 +15,3 @@ export { cleanStackTrace }; | ||
const sackLines__cleaned = stackLines | ||
.filter((line, i) => { | ||
.filter((line) => { | ||
// Remove stack traces related to this package | ||
@@ -22,7 +22,2 @@ if (isSelf(line)) { | ||
// Remove the file that defines the assertion function from the stack trace | ||
if (isSelf(stackLines[i + 1])) { | ||
return false; | ||
} | ||
// Remove internal stack traces | ||
@@ -29,0 +24,0 @@ if (line.includes(" (internal/")) { |
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
66
0
10014
147