Socket
Socket
Sign inDemoInstall

@blackglory/errors

Package Overview
Dependencies
4
Maintainers
1
Versions
24
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.4.3 to 3.0.0

10

lib/assert.js

@@ -1,10 +0,6 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.assert = void 0;
const assertion_error_1 = require("./assertion-error");
function assert(condition, message = 'Assertion failed') {
import { AssertionError } from './assertion-error.js';
export function assert(condition, message = 'Assertion failed') {
if (!condition)
throw new assertion_error_1.AssertionError(message);
throw new AssertionError(message);
}
exports.assert = assert;
//# sourceMappingURL=assert.js.map

@@ -1,3 +0,3 @@

import { CustomError } from './custom-error';
import { CustomError } from './custom-error.js';
export declare class AssertionError extends CustomError {
}

@@ -1,8 +0,4 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.AssertionError = void 0;
const custom_error_1 = require("./custom-error");
class AssertionError extends custom_error_1.CustomError {
import { CustomError } from './custom-error.js';
export class AssertionError extends CustomError {
}
exports.AssertionError = AssertionError;
//# sourceMappingURL=assertion-error.js.map

@@ -1,21 +0,18 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.CustomError = void 0;
const get_error_names_1 = require("./get-error-names");
const is_error_1 = require("./is-error");
const serializable_error_1 = require("./serializable-error");
const utils_1 = require("./utils");
class CustomError extends Error {
import { getErrorNames } from './get-error-names.js';
import { isError } from './is-error.js';
import { isSerializableError } from './serializable-error.js';
import { first, toArray } from './utils.js';
export class CustomError extends Error {
get name() {
var _a, _b;
return (_b = (_a = (0, utils_1.first)((0, get_error_names_1.getErrorNames)(this))) !== null && _a !== void 0 ? _a : CustomError.name) !== null && _b !== void 0 ? _b : 'CustomError';
return (_b = (_a = first(getErrorNames(this))) !== null && _a !== void 0 ? _a : CustomError.name) !== null && _b !== void 0 ? _b : 'CustomError';
}
static [Symbol.hasInstance](instance) {
var _a;
if ((0, is_error_1.isError)(instance) || (0, serializable_error_1.isSerializableError)(instance)) {
if (isError(instance) || isSerializableError(instance)) {
const reversedClassNames = [
(_a = this.prototype.constructor.name) !== null && _a !== void 0 ? _a : this.name,
...(0, get_error_names_1.getErrorNames)(this.prototype)
...getErrorNames(this.prototype)
].reverse();
const reversedInstanceNames = (0, utils_1.toArray)((0, get_error_names_1.getErrorNames)(instance)).reverse();
const reversedInstanceNames = toArray(getErrorNames(instance)).reverse();
return reversedClassNames.every((x, i) => x === reversedInstanceNames[i]);

@@ -28,3 +25,2 @@ }

}
exports.CustomError = CustomError;
//# sourceMappingURL=custom-error.js.map

@@ -1,2 +0,2 @@

import { SerializableError } from './serializable-error';
import { SerializableError } from './serializable-error.js';
export declare function getErrorNames(err: Error | SerializableError): Iterable<string>;

@@ -1,10 +0,7 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getErrorNames = void 0;
const is_error_1 = require("./is-error");
const traverse_error_prototype_chain_1 = require("./traverse-error-prototype-chain");
function* getErrorNames(err) {
import { isError } from './is-error.js';
import { traverseErrorPrototypeChain } from './traverse-error-prototype-chain.js';
export function* getErrorNames(err) {
var _a;
if ((0, is_error_1.isError)(err)) {
for (const prototype of (0, traverse_error_prototype_chain_1.traverseErrorPrototypeChain)(err)) {
if (isError(err)) {
for (const prototype of traverseErrorPrototypeChain(err)) {
if ((_a = prototype.constructor) === null || _a === void 0 ? void 0 : _a.name) {

@@ -20,3 +17,2 @@ yield prototype.constructor.name;

}
exports.getErrorNames = getErrorNames;
//# sourceMappingURL=get-error-names.js.map

@@ -1,2 +0,2 @@

import { SerializableError } from './serializable-error';
import { SerializableError } from './serializable-error.js';
export declare function hydrate(err: SerializableError): Error;

@@ -1,6 +0,3 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.hydrate = void 0;
const pass_1 = require("@blackglory/pass");
function hydrate(err) {
import { pass } from '@blackglory/pass';
export function hydrate(err) {
var _a;

@@ -20,5 +17,4 @@ const errorNames = [err.name, ...err.ancestors]

}
exports.hydrate = hydrate;
function createChildErrorConstructor(parentErrorConstructor, name) {
const constructor = function () { (0, pass_1.pass)(); };
const constructor = function () { pass(); };
constructor.prototype = Object.create(parentErrorConstructor.prototype);

@@ -25,0 +21,0 @@ constructor.prototype.constructor = constructor;

@@ -1,9 +0,9 @@

export * from './custom-error';
export * from './assertion-error';
export * from './serializable-error';
export * from './is-error';
export * from './normalize';
export * from './hydrate';
export * from './assert';
export * from './get-error-names';
export * from './traverse-error-prototype-chain';
export * from './custom-error.js';
export * from './assertion-error.js';
export * from './serializable-error.js';
export * from './is-error.js';
export * from './normalize.js';
export * from './hydrate.js';
export * from './assert.js';
export * from './get-error-names.js';
export * from './traverse-error-prototype-chain.js';

@@ -1,26 +0,10 @@

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
__exportStar(require("./custom-error"), exports);
__exportStar(require("./assertion-error"), exports);
__exportStar(require("./serializable-error"), exports);
__exportStar(require("./is-error"), exports);
__exportStar(require("./normalize"), exports);
__exportStar(require("./hydrate"), exports);
__exportStar(require("./assert"), exports);
__exportStar(require("./get-error-names"), exports);
__exportStar(require("./traverse-error-prototype-chain"), exports);
export * from './custom-error.js';
export * from './assertion-error.js';
export * from './serializable-error.js';
export * from './is-error.js';
export * from './normalize.js';
export * from './hydrate.js';
export * from './assert.js';
export * from './get-error-names.js';
export * from './traverse-error-prototype-chain.js';
//# sourceMappingURL=index.js.map

@@ -1,12 +0,7 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.isntError = exports.isError = void 0;
function isError(val) {
export function isError(val) {
return val instanceof Error;
}
exports.isError = isError;
function isntError(val) {
export function isntError(val) {
return !isError(val);
}
exports.isntError = isntError;
//# sourceMappingURL=is-error.js.map

@@ -1,2 +0,2 @@

import { SerializableError } from './serializable-error';
import { SerializableError } from './serializable-error.js';
export declare function normalize(err: Error): SerializableError;

@@ -1,9 +0,6 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.normalize = void 0;
const get_error_names_1 = require("./get-error-names");
const utils_1 = require("./utils");
function normalize(err) {
import { getErrorNames } from './get-error-names.js';
import { toArray } from './utils.js';
export function normalize(err) {
var _a;
const [name, ...ancestors] = (0, utils_1.toArray)((0, get_error_names_1.getErrorNames)(err));
const [name, ...ancestors] = toArray(getErrorNames(err));
return {

@@ -16,3 +13,2 @@ name,

}
exports.normalize = normalize;
//# sourceMappingURL=normalize.js.map

@@ -1,13 +0,9 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.isSerializableError = void 0;
const types_1 = require("@blackglory/types");
function isSerializableError(val) {
return (0, types_1.isObject)(val)
&& (0, types_1.isString)(val.name)
&& (0, types_1.isString)(val.message)
&& ((0, types_1.isString)(val.stack) || (0, types_1.isNull)(val.stack))
&& ((0, types_1.isArray)(val.ancestors) && val.ancestors.every(types_1.isString));
import { isObject, isString, isArray, isNull } from '@blackglory/types';
export function isSerializableError(val) {
return isObject(val)
&& isString(val.name)
&& isString(val.message)
&& (isString(val.stack) || isNull(val.stack))
&& (isArray(val.ancestors) && val.ancestors.every(isString));
}
exports.isSerializableError = isSerializableError;
//# sourceMappingURL=serializable-error.js.map

@@ -1,5 +0,2 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.traverseErrorPrototypeChain = void 0;
function* traverseErrorPrototypeChain(err) {
export function* traverseErrorPrototypeChain(err) {
let current = err;

@@ -12,3 +9,2 @@ while ((current = Object.getPrototypeOf(current))) {

}
exports.traverseErrorPrototypeChain = traverseErrorPrototypeChain;
//# sourceMappingURL=traverse-error-prototype-chain.js.map

@@ -1,5 +0,2 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.toArray = exports.first = void 0;
function first(iterable) {
export function first(iterable) {
for (const element of iterable) {

@@ -9,7 +6,5 @@ return element;

}
exports.first = first;
function toArray(iterable) {
export function toArray(iterable) {
return Array.from(iterable);
}
exports.toArray = toArray;
//# sourceMappingURL=utils.js.map
{
"name": "@blackglory/errors",
"version": "2.4.3",
"version": "3.0.0",
"description": "Common errors",

@@ -8,2 +8,3 @@ "files": [

],
"type": "module",
"main": "lib/index.js",

@@ -19,11 +20,10 @@ "types": "lib/index.d.ts",

"scripts": {
"prepare": "ts-patch install -s",
"lint": "eslint --ext .js,.jsx,.ts,.tsx --quiet src __tests__",
"test": "jest --config jest.config.js",
"test:debug": "node --inspect-brk node_modules/.bin/jest --runInBand",
"test:coverage": "jest --coverage --config jest.config.js",
"prepublishOnly": "run-s clean build",
"test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest --config jest.config.cjs",
"test:debug": "cross-env NODE_OPTIONS=--experimental-vm-modules node --inspect-brk node_modules/.bin/jest --runInBand --config jest.config.cjs",
"test:coverage": "cross-env NODE_OPTIONS=--experimental-vm-modules jest --coverage --config jest.config.cjs",
"prepublishOnly": "run-s prepare clean build",
"clean": "rimraf lib",
"build": "run-s build:*",
"build:compile": "tsc --project tsconfig.build.json --module commonjs --target es2018 --outDir lib",
"build:patch": "tscpaths -p tsconfig.build.json -s ./src -o ./lib",
"build": "tsc --project tsconfig.build.json --outDir lib",
"release": "standard-version"

@@ -33,3 +33,3 @@ },

"hooks": {
"pre-commit": "run-s lint build test",
"pre-commit": "run-s prepare lint build test",
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS"

@@ -39,2 +39,3 @@ }

"devDependencies": {
"@blackglory/jest-resolver": "^0.3.0",
"@blackglory/log": "^1.3.3",

@@ -46,5 +47,7 @@ "@commitlint/cli": "^17.3.0",

"@typescript-eslint/parser": "^5.46.1",
"cross-env": "^7.0.3",
"eslint": "^8.30.0",
"husky": "^4.3.8",
"jest": "^29.3.1",
"jest-resolve": "^29.3.1",
"npm-run-all": "^4.1.5",

@@ -55,11 +58,12 @@ "return-style": "^1.0.0",

"ts-jest": "^29.0.3",
"tscpaths": "^0.0.9",
"ts-patch": "^2.1.0",
"tsd": "^0.25.0",
"tslib": "^2.4.1",
"typescript": "^4.6.4"
"typescript": "4.8",
"typescript-transform-paths": "^3.4.6"
},
"dependencies": {
"@blackglory/pass": "^1.1.0",
"@blackglory/types": "^1.4.0"
"extra-utils": "^5.0.1"
}
}

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

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

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

Sorry, the diff of this file is not supported yet

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