New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

earljs

Package Overview
Dependencies
Maintainers
2
Versions
45
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

earljs - npm Package Compare versions

Comparing version

to
0.3.0-canary.20230323T174207

2

dist/Control.d.ts

@@ -10,2 +10,3 @@ export interface ValidationResult {

export interface ControlOptions {
name: string;
actual?: unknown;

@@ -16,2 +17,3 @@ isNegated?: boolean;

private readonly _location;
readonly name: string;
readonly actual: unknown;

@@ -18,0 +20,0 @@ isNegated: boolean;

3

dist/Control.js

@@ -26,5 +26,6 @@ "use strict";

};
this.name = options.name;
this.actual = options.actual;
this.isNegated = (_a = options.isNegated) !== null && _a !== void 0 ? _a : false;
this._location = errors_1.AssertionError.getLocation();
this._location = errors_1.AssertionError.getLocation(this.name);
}

@@ -31,0 +32,0 @@ get file() {

@@ -15,8 +15,7 @@ interface AssertionErrorOptions {

constructor(options: AssertionErrorOptions);
static getLocation(): {
static getLocation(name: string): {
file: string | undefined;
stack: string;
};
private static getCleanStack;
}
export {};

@@ -21,22 +21,45 @@ "use strict";

}
static getLocation() {
static getLocation(name) {
var _a;
const error = new Error('message');
const stack = this.getCleanStack(error);
const file = (_a = error_stack_parser_1.default.parse({ stack })[0]) === null || _a === void 0 ? void 0 : _a.fileName;
return { file, stack };
const cleaned = getCleanStack(error);
const parsed = error_stack_parser_1.default.parse({ stack: cleaned });
return {
file: (_a = parsed[0]) === null || _a === void 0 ? void 0 : _a.fileName,
stack: formatStack(name, parsed),
};
}
static getCleanStack(error) {
var _a, _b;
const depth = 4;
if ((_a = error.stack) === null || _a === void 0 ? void 0 : _a.startsWith('Error: message\n')) {
return error.stack
.split('\n')
.slice(depth + 1)
.join('\n');
}
return (_b = error.stack) !== null && _b !== void 0 ? _b : '';
}
exports.AssertionError = AssertionError;
function getCleanStack(error) {
var _a, _b, _c, _d, _e, _f;
const lines = (_b = (_a = error.stack) === null || _a === void 0 ? void 0 : _a.split('\n')) !== null && _b !== void 0 ? _b : [];
if ((_c = lines[0]) === null || _c === void 0 ? void 0 : _c.startsWith('Error: message')) {
return lines.slice(5).join('\n');
}
if (((_d = lines[0]) === null || _d === void 0 ? void 0 : _d.includes('AssertionError')) && ((_e = lines[2]) === null || _e === void 0 ? void 0 : _e.includes('^'))) {
// in esbuild-register context is added to the stack trace
return lines.slice(9).join('\n');
}
return (_f = error.stack) !== null && _f !== void 0 ? _f : '';
}
exports.AssertionError = AssertionError;
function formatStack(name, stack) {
return stack
.map((frame, i) => {
let file = frame.fileName;
if (file !== undefined && frame.lineNumber !== undefined) {
file += `:${frame.lineNumber}`;
if (frame.columnNumber !== undefined) {
file += `:${frame.columnNumber}`;
}
}
if (i === 0) {
return file === undefined
? ` at ${name}`
: ` at ${name} (${file})`;
}
return frame.source;
})
.join('\n');
}
//# sourceMappingURL=AssertionError.js.map

@@ -28,4 +28,11 @@ "use strict";

}
_getControl() {
return new Control_1.Control({ actual: this._value, isNegated: this._negated });
_getControl(name) {
const functionName = this._negated
? `expect().not.${name}`
: `expect().${name}`;
return new Control_1.Control({
name: functionName,
actual: this._value,
isNegated: this._negated,
});
}

@@ -35,3 +42,3 @@ }

function execute(...args) {
return validator(this._getControl(), ...args);
return validator(this._getControl(name), ...args);
}

@@ -38,0 +45,0 @@ Object.defineProperty(execute, 'name', { value: name, writable: false });

@@ -24,3 +24,3 @@ {

"license": "MIT",
"version": "0.3.0-canary.20230323T142857",
"version": "0.3.0-canary.20230323T174207",
"main": "./dist/index.js",

@@ -27,0 +27,0 @@ "types": "./dist/index.d.ts",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet