Socket
Socket
Sign inDemoInstall

errlop

Package Overview
Dependencies
Maintainers
2
Versions
110
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

errlop - npm Package Compare versions

Comparing version 1.7.0 to 2.0.0-next.1576046684.95552244bf860eb18e4041a3ee1f82731fb86c12

edition-es5/index.js

256

edition-browsers/index.js
'use strict';
/**
* Only accept codes that are numbers, otherwise discard them
* @param {*} code
* @returns {number}
* @private
*/
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); }
function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); }
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
function _wrapNativeSuper(Class) { var _cache = typeof Map === "function" ? new Map() : undefined; _wrapNativeSuper = function _wrapNativeSuper(Class) { if (Class === null || !_isNativeFunction(Class)) return Class; if (typeof Class !== "function") { throw new TypeError("Super expression must either be null or a function"); } if (typeof _cache !== "undefined") { if (_cache.has(Class)) return _cache.get(Class); _cache.set(Class, Wrapper); } function Wrapper() { return _construct(Class, arguments, _getPrototypeOf(this).constructor); } Wrapper.prototype = Object.create(Class.prototype, { constructor: { value: Wrapper, enumerable: false, writable: true, configurable: true } }); return _setPrototypeOf(Wrapper, Class); }; return _wrapNativeSuper(Class); }
function isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
function _construct(Parent, args, Class) { if (isNativeReflectConstruct()) { _construct = Reflect.construct; } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); }
function _isNativeFunction(fn) { return Function.toString.call(fn).indexOf("[native code]") !== -1; }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
/** Only accept codes that are numbers, otherwise discard them */
function parseCode(code) {
var 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
* @param {Object|Error} value
* @returns {boolean}
* @private
*/
/** 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.
* @param {*} value
* @returns {boolean}
* @private
*/
/** 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);
}
/**
* 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
* @class Errlop
* @constructor
* @param {Errlop|Error|Object|string} input
* @param {Errlop|Error} [parent]
* @public
*/
var Errlop =
/*#__PURE__*/
function (_Error) {
_inherits(Errlop, _Error);
function Errlop(input, parent) {
var _this;
_classCallCheck(this, Errlop);
if (!input) throw new Error('Attempted to create an Errlop without a input'); // Instantiate with the above
_this = _possibleConstructorReturn(this, _getPrototypeOf(Errlop).call(this, input.message || input));
export default class Errlop extends Error {
/**
* Duck typing as node 4 and intanceof does not work for error extensions
* @type {Errlop}
* @public
* 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
*/
_this.klass = Errlop;
/**
* The parent error if it was provided.
* If a parent was provided, then use that, otherwise use the input's parent, if it exists.
* @type {Error?}
* @public
*/
_this.parent = parent || input.parent;
/**
* An array of all the ancestors. From parent, to grand parent, and so on.
* @type {Array<Error>}
* @public
*/
_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(_assertThisInitialized(_this));
for (var index = 0; index < _this.ancestors.length && exitCode == null; ++index) {
var error = _this.ancestors[index];
if (isValid(error)) exitCode = fetchCode(error);
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);
}
/**
* A numeric code to use for the exit status if desired by the consumer.
* It cycles through [input, this, ...ancestors] until it finds the first [exitCode, errno, code] that is valid.
* @type {Number?}
* @public
* Syntatic sugar for Errlop class creation.
* Enables `Errlop.create(...args)` to achieve `new Errlop(...args)`
*/
_this.exitCode = exitCode;
/**
* The stack for our instance alone, without any parents.
* If the input contained a stack, then use that.
* @type {string}
* @public
*/
_this.orphanStack = (input.stack || _this.stack).toString();
/**
* The stack which now contains the accumalated stacks of its ancestors.
* This is used instead of an alias like `fullStack` or the like, to ensure existing code that uses `err.stack` doesn't need to be changed to remain functional.
* @type {string}
* @public
*/
_this.stack = [_this.orphanStack].concat(_toConsumableArray(_this.ancestors)).reduce(function (accumulator, error) {
return "".concat(accumulator, "\n\u21B3 ").concat(error.orphanStack || error.stack || error);
});
return _this;
}
/**
* Syntatic sugar for Errlop class creation.
* Enables `Errlop.create(...args)` to achieve `new Errlop(...args)`
* @param {...*} args
* @returns {Errlop}
* @static
* @public
*/
_createClass(Errlop, null, [{
key: "create",
value: function create() {
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
return _construct(this, args);
static create(input, parent) {
return new this(input, parent);
}
/**
* Check whether or not the value is an Errlop instance
* @param {*} value
* @returns {boolean}
* @static
* @public
*/
}, {
key: "isErrlop",
value: function isErrlop(value) {
return value && (value instanceof this || value.klass === this);
/** 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
* @param {*} value
* @returns {Errlop}
* @static
* @public
*/
}, {
key: "ensure",
value: function ensure(value) {
return this.isErrlop(value) ? value : this.create(value);
/** Ensure that the value is an Errlop instance */
static ensure(value) {
return this.isErrlop(value) ? value : this.create(value);
}
}]);
return Errlop;
}(_wrapNativeSuper(Error));
module.exports = Errlop;
}
# History
## v2.0.0 2019 December 11
- Errlop is now written in TypeScript
- Errlop's browser edition now makes use of ECMAScript modules
- Errlop now only includes one Node.js edition that runs on all Node.js environments
- Updated dependencies, [base files](https://github.com/bevry/base), and [editions](https://editions.bevry.me) using [boundation](https://github.com/bevry/boundation)
## v1.7.0 2019 December 9

@@ -4,0 +11,0 @@

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

@@ -68,17 +68,13 @@ "homepage": "https://github.com/bevry/errlop",

{
"description": "esnext source code with require for modules",
"description": "typescript source code with import for modules",
"directory": "source",
"entry": "index.js",
"entry": "index.ts",
"tags": [
"javascript",
"esnext",
"require"
"typescript",
"import"
],
"engines": {
"node": "6 || 8 || 10 || 12",
"browsers": false
}
"engines": false
},
{
"description": "esnext compiled for browsers with require for modules",
"description": "typescript compiled against ESNext for web browsers with import for modules",
"directory": "edition-browsers",

@@ -88,3 +84,3 @@ "entry": "index.js",

"javascript",
"require"
"import"
],

@@ -97,11 +93,12 @@ "engines": {

{
"description": "esnext compiled for node.js 0.8 with require for modules",
"directory": "edition-node-0.8",
"description": "typescript compiled against ES5 for Node.js with require for modules",
"directory": "edition-es5",
"entry": "index.js",
"tags": [
"javascript",
"es5",
"require"
],
"engines": {
"node": "0.8 || 0.10 || 0.12 || 4 || 6 || 8 || 10 || 12",
"node": "0.8 || 0.10 || 0.12 || 4 || 6 || 8 || 10 || 12 || 13",
"browsers": false

@@ -111,35 +108,32 @@ }

],
"types": "source/index.ts",
"type": "commonjs",
"main": "index.js",
"main": "edition-es5/index.js",
"browser": "edition-browsers/index.js",
"dependencies": {
"editions": "^2.2.0"
},
"module": "edition-browsers/index.js",
"devDependencies": {
"@babel/cli": "^7.7.5",
"@babel/core": "^7.7.5",
"@babel/plugin-proposal-object-rest-spread": "^7.7.4",
"@babel/preset-env": "^7.7.6",
"@typescript-eslint/eslint-plugin": "^2.11.0",
"@typescript-eslint/parser": "^2.11.0",
"assert-helpers": "4.10.0",
"eslint": "^6.7.2",
"eslint-config-bevry": "^2.2.0",
"eslint-config-bevry": "^2.3.0",
"eslint-config-prettier": "^6.7.0",
"eslint-plugin-prettier": "^3.1.1",
"jsdoc": "^3.6.3",
"kava": "3.2.0",
"minami": "^1.2.3",
"prettier": "^1.19.1",
"projectz": "^1.15.0",
"projectz": "^1.16.0",
"surge": "^0.21.3",
"valid-directory": "^1.5.0"
"typedoc": "^0.15.4",
"typescript": "^3.7.3",
"valid-directory": "^1.6.0"
},
"scripts": {
"our:clean": "rm -Rf ./docs ./edition* ./es2015 ./es5 ./out ./.next",
"our:compile": "npm run our:compile:edition-browsers && npm run our:compile:edition-node-0.8",
"our:compile:edition-browsers": "env BABEL_ENV=edition-browsers babel --out-dir ./edition-browsers ./source",
"our:compile:edition-node-0.8": "env BABEL_ENV=edition-node-0.8 babel --out-dir ./edition-node-0.8 ./source",
"our:compile": "npm run our:compile:edition-browsers && npm run our:compile:edition-es5",
"our:compile:edition-browsers": "tsc --module ESNext --target ESNext --outDir ./edition-browsers --project tsconfig.json && test -d edition-browsers/source && ( mv edition-browsers/source edition-temp && rm -Rf edition-browsers && mv edition-temp edition-browsers ) || true",
"our:compile:edition-es5": "tsc --module commonjs --target ES5 --outDir ./edition-es5 --project tsconfig.json && test -d edition-es5/source && ( mv edition-es5/source edition-temp && rm -Rf edition-es5 && mv edition-temp edition-es5 ) || true",
"our:deploy": "echo no need for this project",
"our:meta": "npm run our:meta:docs && npm run our:meta:projectz",
"our:meta:docs": "npm run our:meta:docs:jsdoc",
"our:meta:docs:jsdoc": "rm -Rf ./docs && jsdoc --recurse --pedantic --access all --destination ./docs --package ./package.json --readme ./README.md --template ./node_modules/minami ./source && mv ./docs/$npm_package_name/$npm_package_version/* ./docs/ && rm -Rf ./docs/$npm_package_name/$npm_package_version",
"our:meta:docs": "npm run our:meta:docs:typedoc",
"our:meta:docs:typedoc": "rm -Rf ./docs && typedoc --mode file --exclude '**/+(*test*|node_modules)' --excludeExternals --name \"$npm_package_name\" --readme ./README.md --out ./docs ./source",
"our:meta:projectz": "projectz compile",

@@ -155,7 +149,8 @@ "our:release": "npm run our:release:prepare && npm run our:release:check-changelog && npm run our:release:check-dirty && npm run our:release:tag && npm run our:release:push",

"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",
"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: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/**",
"test": "node ./test.js"
"our:verify:typescript": "tsc --noEmit --project tsconfig.json",
"test": "node ./edition-es5/test.js"
},

@@ -171,42 +166,11 @@ "eslintConfig": {

},
"babel": {
"env": {
"edition-browsers": {
"sourceType": "script",
"presets": [
[
"@babel/preset-env",
{
"targets": "defaults",
"modules": false
}
]
],
"plugins": [
"@babel/proposal-object-rest-spread"
]
},
"edition-node-0.8": {
"sourceType": "script",
"presets": [
[
"@babel/preset-env",
{
"targets": {
"node": "0.8"
},
"modules": false
}
]
],
"plugins": [
"@babel/proposal-object-rest-spread"
]
}
}
},
"boundation": {
"minimumSupportNodeVersion": "0.8",
"minimumTestNodeVersion": "0.8"
"minimumTestNodeVersion": "0.8",
"compiler": "typescript",
"targets": [
"browser",
"ES5"
]
}
}

@@ -58,19 +58,7 @@ <!-- TITLE/ -->

<ul><li><code>errlop</code> aliases <code>errlop/index.js</code> which uses <a href="https://editions.bevry.me" title="Editions are the best way to produce and consume packages you care about.">Editions</a> to automatically select the correct edition for the consumers environment</li>
<li><code>errlop/source/index.js</code> is esnext source code with require for modules</li>
<li><code>errlop/edition-browsers/index.js</code> is esnext compiled for browsers with require for modules</li>
<li><code>errlop/edition-node-0.8/index.js</code> is esnext compiled for node.js 0.8 with require for modules</li></ul>
<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>
<h3><a href="https://www.typescriptlang.org/" title="TypeScript is a typed superset of JavaScript that compiles to plain JavaScript. ">TypeScript</a></h3>
This project provides its type information via inline <a href="http://usejsdoc.org" title="JSDoc is an API documentation generator for JavaScript, similar to Javadoc or phpDocumentor">JSDoc Comments</a>. To make use of this in <a href="https://www.typescriptlang.org/" title="TypeScript is a typed superset of JavaScript that compiles to plain JavaScript. ">TypeScript</a>, set your <code>maxNodeModuleJsDepth</code> compiler option to `5` or thereabouts. You can accomlish this via your `tsconfig.json` file like so:
``` json
{
"compilerOptions": {
"maxNodeModuleJsDepth": 5
}
}
```
<!-- /INSTALL -->

@@ -77,0 +65,0 @@

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc