Socket
Socket
Sign inDemoInstall

@brillout/libassert

Package Overview
Dependencies
0
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.2.0 to 0.2.1

6

dist/cleanStackTrace.js

@@ -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/")) {

2

package.json
{
"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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc