Socket
Socket
Sign inDemoInstall

errlop

Package Overview
Dependencies
0
Maintainers
2
Versions
110
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.0.0 to 2.1.0-next.1585176392.a09b5b6717e1d35a9c826925e358226aa96cd945

130

edition-browsers/index.js

@@ -1,74 +0,78 @@

'use strict';
'use strict'
/** Only accept codes that are numbers, otherwise discard them */
function parseCode(code) {
const number = Number(code);
if (isNaN(number))
return null;
return number;
const number = Number(code)
if (isNaN(number)) return null
return number
}
/** Fetch the code from the value */
function fetchCode(value) {
return (value &&
(parseCode(value.exitCode) ||
parseCode(value.errno) ||
parseCode(value.code)));
return (
value &&
(parseCode(value.exitCode) ||
parseCode(value.errno) ||
parseCode(value.code))
)
}
/** Prevent [a weird error on node version 4](https://github.com/bevry/errlop/issues/1) and below. */
function isValid(value) {
/* eslint no-use-before-define:0 */
return value instanceof Error || Errlop.isErrlop(value);
/* eslint no-use-before-define:0 */
return value instanceof Error || Errlop.isErrlop(value)
}
export default class Errlop extends Error {
/**
* Create an instance of an error, using a message, as well as an optional parent.
* If the parent is provided, then the `fullStack` property will include its stack too
*/
constructor(input, parent) {
if (!input)
throw new Error('Attempted to create an Errlop without a input');
// Instantiate with the above
super(input.message || input);
// Apply
this.klass = Errlop;
this.parent = parent || input.parent;
this.ancestors = [];
let ancestor = this.parent;
while (ancestor) {
this.ancestors.push(ancestor);
ancestor = ancestor.parent;
}
// this code must support node 0.8, as well as prevent a weird bug in node v4
// https://travis-ci.org/bevry/editions/jobs/408828147
let exitCode = fetchCode(input);
if (exitCode == null)
exitCode = fetchCode(this);
for (let index = 0; index < this.ancestors.length && exitCode == null; ++index) {
const error = this.ancestors[index];
if (isValid(error))
exitCode = fetchCode(error);
}
// Apply
if (exitCode != null) {
this.exitCode = exitCode;
}
this.orphanStack = (input.stack || this.stack).toString();
this.stack = this.ancestors.reduce((accumulator, error) => `${accumulator}\n↳ ${error.orphanStack ||
error.stack ||
error}`, this.orphanStack);
}
/**
* Syntatic sugar for Errlop class creation.
* Enables `Errlop.create(...args)` to achieve `new Errlop(...args)`
*/
static create(input, parent) {
return new this(input, parent);
}
/** Check whether or not the value is an Errlop instance */
static isErrlop(value) {
return value && (value instanceof this || value.klass === this);
}
/** Ensure that the value is an Errlop instance */
static ensure(value) {
return this.isErrlop(value) ? value : this.create(value);
}
/**
* Create an instance of an error, using a message, as well as an optional parent.
* If the parent is provided, then the `fullStack` property will include its stack too
*/
constructor(input, parent) {
if (!input) throw new Error('Attempted to create an Errlop without a input')
// Instantiate with the above
super(input.message || input)
// Apply
this.klass = Errlop
this.parent = parent || input.parent
this.ancestors = []
let ancestor = this.parent
while (ancestor) {
this.ancestors.push(ancestor)
ancestor = ancestor.parent
}
// this code must support node 0.8, as well as prevent a weird bug in node v4
// https://travis-ci.org/bevry/editions/jobs/408828147
let exitCode = fetchCode(input)
if (exitCode == null) exitCode = fetchCode(this)
for (
let index = 0;
index < this.ancestors.length && exitCode == null;
++index
) {
const error = this.ancestors[index]
if (isValid(error)) exitCode = fetchCode(error)
}
// Apply
if (exitCode != null) {
this.exitCode = exitCode
}
this.orphanStack = (input.stack || this.stack).toString()
this.stack = this.ancestors.reduce(
(accumulator, error) =>
`${accumulator}\n↳ ${error.orphanStack || error.stack || error}`,
this.orphanStack
)
}
/**
* Syntatic sugar for Errlop class creation.
* Enables `Errlop.create(...args)` to achieve `new Errlop(...args)`
*/
static create(input, parent) {
return new this(input, parent)
}
/** Check whether or not the value is an Errlop instance */
static isErrlop(value) {
return value && (value instanceof this || value.klass === this)
}
/** Ensure that the value is an Errlop instance */
static ensure(value) {
return this.isErrlop(value) ? value : this.create(value)
}
}

@@ -1,95 +0,108 @@

'use strict';
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
'use strict'
var __extends =
(this && this.__extends) ||
(function () {
var extendStatics = function (d, b) {
extendStatics =
Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array &&
function (d, b) {
d.__proto__ = b
}) ||
function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]
}
return extendStatics(d, b)
}
return function (d, b) {
extendStatics(d, b)
function __() {
this.constructor = d
}
d.prototype =
b === null ? Object.create(b) : ((__.prototype = b.prototype), new __())
}
})()
Object.defineProperty(exports, '__esModule', { value: true })
/** Only accept codes that are numbers, otherwise discard them */
function parseCode(code) {
var number = Number(code);
if (isNaN(number))
return null;
return number;
var number = Number(code)
if (isNaN(number)) return null
return number
}
/** Fetch the code from the value */
function fetchCode(value) {
return (value &&
(parseCode(value.exitCode) ||
parseCode(value.errno) ||
parseCode(value.code)));
return (
value &&
(parseCode(value.exitCode) ||
parseCode(value.errno) ||
parseCode(value.code))
)
}
/** Prevent [a weird error on node version 4](https://github.com/bevry/errlop/issues/1) and below. */
function isValid(value) {
/* eslint no-use-before-define:0 */
return value instanceof Error || Errlop.isErrlop(value);
/* eslint no-use-before-define:0 */
return value instanceof Error || Errlop.isErrlop(value)
}
var Errlop = /** @class */ (function (_super) {
__extends(Errlop, _super);
/**
* Create an instance of an error, using a message, as well as an optional parent.
* If the parent is provided, then the `fullStack` property will include its stack too
*/
function Errlop(input, parent) {
var _this = this;
if (!input)
throw new Error('Attempted to create an Errlop without a input');
// Instantiate with the above
_this = _super.call(this, input.message || input) || this;
// Apply
_this.klass = Errlop;
_this.parent = parent || input.parent;
_this.ancestors = [];
var ancestor = _this.parent;
while (ancestor) {
_this.ancestors.push(ancestor);
ancestor = ancestor.parent;
}
// this code must support node 0.8, as well as prevent a weird bug in node v4
// https://travis-ci.org/bevry/editions/jobs/408828147
var exitCode = fetchCode(input);
if (exitCode == null)
exitCode = fetchCode(_this);
for (var index = 0; index < _this.ancestors.length && exitCode == null; ++index) {
var error = _this.ancestors[index];
if (isValid(error))
exitCode = fetchCode(error);
}
// Apply
if (exitCode != null) {
_this.exitCode = exitCode;
}
_this.orphanStack = (input.stack || _this.stack).toString();
_this.stack = _this.ancestors.reduce(function (accumulator, error) {
return accumulator + "\n\u21B3 " + (error.orphanStack ||
error.stack ||
error);
}, _this.orphanStack);
return _this;
}
/**
* Syntatic sugar for Errlop class creation.
* Enables `Errlop.create(...args)` to achieve `new Errlop(...args)`
*/
Errlop.create = function (input, parent) {
return new this(input, parent);
};
/** Check whether or not the value is an Errlop instance */
Errlop.isErrlop = function (value) {
return value && (value instanceof this || value.klass === this);
};
/** Ensure that the value is an Errlop instance */
Errlop.ensure = function (value) {
return this.isErrlop(value) ? value : this.create(value);
};
return Errlop;
}(Error));
exports.default = Errlop;
__extends(Errlop, _super)
/**
* Create an instance of an error, using a message, as well as an optional parent.
* If the parent is provided, then the `fullStack` property will include its stack too
*/
function Errlop(input, parent) {
var _this = this
if (!input) throw new Error('Attempted to create an Errlop without a input')
// Instantiate with the above
_this = _super.call(this, input.message || input) || this
// Apply
_this.klass = Errlop
_this.parent = parent || input.parent
_this.ancestors = []
var ancestor = _this.parent
while (ancestor) {
_this.ancestors.push(ancestor)
ancestor = ancestor.parent
}
// this code must support node 0.8, as well as prevent a weird bug in node v4
// https://travis-ci.org/bevry/editions/jobs/408828147
var exitCode = fetchCode(input)
if (exitCode == null) exitCode = fetchCode(_this)
for (
var index = 0;
index < _this.ancestors.length && exitCode == null;
++index
) {
var error = _this.ancestors[index]
if (isValid(error)) exitCode = fetchCode(error)
}
// Apply
if (exitCode != null) {
_this.exitCode = exitCode
}
_this.orphanStack = (input.stack || _this.stack).toString()
_this.stack = _this.ancestors.reduce(function (accumulator, error) {
return (
accumulator + '\n\u21B3 ' + (error.orphanStack || error.stack || error)
)
}, _this.orphanStack)
return _this
}
/**
* Syntatic sugar for Errlop class creation.
* Enables `Errlop.create(...args)` to achieve `new Errlop(...args)`
*/
Errlop.create = function (input, parent) {
return new this(input, parent)
}
/** Check whether or not the value is an Errlop instance */
Errlop.isErrlop = function (value) {
return value && (value instanceof this || value.klass === this)
}
/** Ensure that the value is an Errlop instance */
Errlop.ensure = function (value) {
return this.isErrlop(value) ? value : this.create(value)
}
return Errlop
})(Error)
exports.default = Errlop
# History
## v2.1.0 2020 March 26
- Updated dependencies, [base files](https://github.com/bevry/base), and [editions](https://editions.bevry.me) using [boundation](https://github.com/bevry/boundation)
## v2.0.0 2019 December 11

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

{
"name": "errlop",
"version": "2.0.0",
"version": "2.1.0-next.1585176392.a09b5b6717e1d35a9c826925e358226aa96cd945",
"description": "An extended Error class that envelops a parent error, such that the stack trace contains the causation",

@@ -8,9 +8,15 @@ "homepage": "https://github.com/bevry/errlop",

"keywords": [
"browser",
"error",
"export-default",
"module",
"nerror",
"nested",
"nested-error",
"nerror",
"verror",
"ono",
"simple",
"ono"
"typed",
"types",
"typescript",
"verror"
],

@@ -54,4 +60,3 @@ "badges": {

"contributors": [
"Benjamin Lupton (http://balupton.com)",
"dependabot-preview[bot] (http://github.com/apps/dependabot-preview)"
"Benjamin Lupton (http://balupton.com)"
],

@@ -70,3 +75,3 @@ "bugs": {

{
"description": "typescript source code with import for modules",
"description": "TypeScript source code with Import for modules",
"directory": "source",

@@ -81,3 +86,3 @@ "entry": "index.ts",

{
"description": "typescript compiled against ESNext for web browsers with import for modules",
"description": "TypeScript compiled against ESNext for web browsers with Import for modules",
"directory": "edition-browsers",

@@ -95,3 +100,3 @@ "entry": "index.js",

{
"description": "typescript compiled against ES5 for Node.js with require for modules",
"description": "TypeScript compiled against ES5 for Node.js with Require for modules",
"directory": "edition-es5",

@@ -105,3 +110,3 @@ "entry": "index.js",

"engines": {
"node": "0.8 || 0.10 || 0.12 || 4 || 6 || 8 || 10 || 12 || 13",
"node": "0.8 || 0.10 || 0.12 || 4 || 6 || 8 || 10 || 12",
"browsers": false

@@ -117,16 +122,17 @@ }

"devDependencies": {
"@typescript-eslint/eslint-plugin": "^2.11.0",
"@typescript-eslint/parser": "^2.11.0",
"@typescript-eslint/eslint-plugin": "^2.25.0",
"@typescript-eslint/parser": "^2.25.0",
"assert-helpers": "4.10.0",
"eslint": "^6.7.2",
"eslint": "^6.8.0",
"eslint-config-bevry": "^2.3.0",
"eslint-config-prettier": "^6.7.0",
"eslint-plugin-prettier": "^3.1.1",
"eslint-config-prettier": "^6.10.1",
"eslint-plugin-prettier": "^3.1.2",
"kava": "3.2.0",
"prettier": "^1.19.1",
"projectz": "^1.16.0",
"prettier": "^2.0.2",
"projectz": "^1.19.0",
"surge": "^0.21.3",
"typedoc": "^0.15.4",
"typescript": "^3.7.3",
"valid-directory": "^1.6.0"
"typedoc": "^0.17.3",
"typescript": "^3.8.3",
"valid-directory": "^1.6.0",
"valid-module": "^1.0.0"
},

@@ -152,6 +158,7 @@ "scripts": {

"our:test": "npm run our:verify && npm test",
"our:verify": "npm run our:verify:directory && npm run our:verify:eslint && npm run our:verify:prettier && npm run our:verify:typescript",
"our:verify:directory": "npx valid-directory",
"our:verify": "npm run our:verify:directory && npm run our:verify:eslint && npm run our:verify:module && npm run our:verify:prettier && npm run our:verify:typescript",
"our:verify:directory": "valid-directory",
"our:verify:eslint": "eslint --fix --ignore-pattern '**/*.d.ts' --ignore-pattern '**/vendor/' --ignore-pattern '**/node_modules/' --ext .mjs,.js,.jsx,.ts,.tsx ./source",
"our:verify:prettier": "prettier --write ./source/**",
"our:verify:module": "valid-module",
"our:verify:prettier": "prettier --write .",
"our:verify:typescript": "tsc --noEmit --project tsconfig.json",

@@ -158,0 +165,0 @@ "test": "node ./edition-es5/test.js"

@@ -36,38 +36,9 @@ <!-- TITLE/ -->

<!-- INSTALL/ -->
<h2>Install</h2>
<a href="https://npmjs.com" title="npm is a package manager for javascript"><h3>npm</h3></a>
<ul>
<li>Install: <code>npm install --save errlop</code></li>
<li>Require: <code>require('errlop')</code></li>
</ul>
<a href="https://jspm.io" title="Native ES Modules CDN"><h3>jspm</h3></a>
``` html
<script type="module">
import * as pkg from '//dev.jspm.io/errlop'
</script>
```
<h3><a href="https://editions.bevry.me" title="Editions are the best way to produce and consume packages you care about.">Editions</a></h3>
<p>This package is published with the following editions:</p>
<ul><li><code>errlop/source/index.ts</code> is typescript source code with import for modules</li>
<li><code>errlop/edition-browsers/index.js</code> is typescript compiled against <a href="https://babeljs.io/docs/learn-es2015/" title="ECMAScript Next">ESNext</a> for web browsers with import for modules</li>
<li><code>errlop</code> aliases <code>errlop/edition-es5/index.js</code></li>
<li><code>errlop/edition-es5/index.js</code> is typescript compiled against ES5 for Node.js with require for modules</li></ul>
<!-- /INSTALL -->
## Usage
[Complete API Documentation.](http://master.errlop.bevry.surge.sh/docs/)
[Complete API Documentation.](http://master.errlop.bevry.surge.sh/docs/globals.html)
``` javascript
const Errlop = require('errlop')
```javascript
// const Errlop = require('errlop').default
import Errlop from 'errlop'
const a = new Errlop('AError')

@@ -125,3 +96,49 @@ const b = new Errlop('BError', a)

<!-- INSTALL/ -->
<h2>Install</h2>
<a href="https://npmjs.com" title="npm is a package manager for javascript"><h3>npm</h3></a>
<ul>
<li>Install: <code>npm install --save errlop</code></li>
<li>Import: <code>import pkg from ('errlop')</code></li>
<li>Require: <code>const pkg = require('errlop').default</code></li>
</ul>
<a href="https://www.pika.dev/cdn" title="100% Native ES Modules CDN"><h3>pika</h3></a>
``` html
<script type="module">
import pkg from '//cdn.pika.dev/errlop/^2.1.0'
</script>
```
<a href="https://unpkg.com" title="unpkg is a fast, global content delivery network for everything on npm"><h3>unpkg</h3></a>
``` html
<script type="module">
import pkg from '//unpkg.com/errlop@^2.1.0'
</script>
```
<a href="https://jspm.io" title="Native ES Modules CDN"><h3>jspm</h3></a>
``` html
<script type="module">
import pkg from '//dev.jspm.io/errlop@2.1.0'
</script>
```
<h3><a href="https://editions.bevry.me" title="Editions are the best way to produce and consume packages you care about.">Editions</a></h3>
<p>This package is published with the following editions:</p>
<ul><li><code>errlop/source/index.ts</code> is <a href="https://www.typescriptlang.org/" title="TypeScript is a typed superset of JavaScript that compiles to plain JavaScript. ">TypeScript</a> source code with <a href="https://babeljs.io/docs/learn-es2015/#modules" title="ECMAScript Modules">Import</a> for modules</li>
<li><code>errlop/edition-browsers/index.js</code> is <a href="https://www.typescriptlang.org/" title="TypeScript is a typed superset of JavaScript that compiles to plain JavaScript. ">TypeScript</a> compiled against <a href="https://en.wikipedia.org/wiki/ECMAScript#ES.Next" title="ECMAScript Next">ESNext</a> for web browsers with <a href="https://babeljs.io/docs/learn-es2015/#modules" title="ECMAScript Modules">Import</a> for modules</li>
<li><code>errlop</code> aliases <code>errlop/edition-es5/index.js</code></li>
<li><code>errlop/edition-es5/index.js</code> is <a href="https://www.typescriptlang.org/" title="TypeScript is a typed superset of JavaScript that compiles to plain JavaScript. ">TypeScript</a> compiled against ES5 for <a href="https://nodejs.org" title="Node.js is a JavaScript runtime built on Chrome's V8 JavaScript engine">Node.js</a> with <a href="https://nodejs.org/dist/latest-v5.x/docs/api/modules.html" title="Node/CJS Modules">Require</a> for modules</li></ul>
<!-- /INSTALL -->
<!-- HISTORY/ -->

@@ -153,3 +170,3 @@

<ul><li><a href="http://balupton.com">Benjamin Lupton</a> — <a href="https://github.com/bevry/errlop/commits?author=balupton" title="View the GitHub contributions of Benjamin Lupton on repository bevry/errlop">view contributions</a></li></ul>
<ul><li><a href="http://balupton.com">Benjamin Lupton</a></li></ul>

@@ -174,4 +191,3 @@ <h3>Sponsors</h3>

<ul><li><a href="http://balupton.com">Benjamin Lupton</a> — <a href="https://github.com/bevry/errlop/commits?author=balupton" title="View the GitHub contributions of Benjamin Lupton on repository bevry/errlop">view contributions</a></li>
<li><a href="http://github.com/apps/dependabot-preview">dependabot-preview[bot]</a> — <a href="https://github.com/bevry/errlop/commits?author=dependabot-preview[bot]" title="View the GitHub contributions of dependabot-preview[bot] on repository bevry/errlop">view contributions</a></li></ul>
<ul><li><a href="http://balupton.com">Benjamin Lupton</a></li></ul>

@@ -178,0 +194,0 @@ <a href="https://github.com/bevry/errlop/blob/master/CONTRIBUTING.md#files">Discover how you can contribute by heading on over to the <code>CONTRIBUTING.md</code> file.</a>

@@ -112,5 +112,5 @@ 'use strict'

(accumulator, error) =>
`${accumulator}\n↳ ${(error as Errlop).orphanStack ||
(error as Error).stack ||
error}`,
`${accumulator}\n↳ ${
(error as Errlop).orphanStack || (error as Error).stack || error
}`,
this.orphanStack

@@ -117,0 +117,0 @@ )

@@ -11,5 +11,3 @@ {

},
"include": [
"source"
]
"include": ["source"]
}
SocketSocket SOC 2 Logo

Product

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc