Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

pretty-error

Package Overview
Dependencies
Maintainers
1
Versions
35
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pretty-error - npm Package Compare versions

Comparing version 2.2.0-rc.1 to 3.0.2

.mocharc.yaml

90

index.d.ts
declare module 'pretty-error' {
namespace PrettyError {

@@ -8,20 +7,20 @@ function start(): any;

class ParsedError {
constructor( error:Error );
constructor(error: Error);
}
interface ConfigObject {
skipPackages?:boolean | string[],
skipPaths?:boolean | string[],
skip?:boolean | PrettyError.Callback | PrettyError.Callback[],
maxItems?:number,
skipNodeFiles?:boolean | any // assuming this is optional
filters?:boolean | PrettyError.Callback | PrettyError.Callback[],
parsedErrorFilters?:boolean | PrettyError.Callback | PrettyError.Callback[],
aliases?:boolean | Object
skipPackages?: boolean | string[];
skipPaths?: boolean | string[];
skip?: boolean | PrettyError.Callback | PrettyError.Callback[];
maxItems?: number;
skipNodeFiles?: boolean | any; // assuming this is optional
filters?: boolean | PrettyError.Callback | PrettyError.Callback[];
parsedErrorFilters?:
| boolean
| PrettyError.Callback
| PrettyError.Callback[];
aliases?: boolean | Object;
}
interface Callback {
traceLine:Object | any,
lineNumber:number
}
type Callback = (traceLine: Object | any, lineNumber: number) => boolean;
}

@@ -32,35 +31,38 @@

start():PrettyError;
stop():any;
config( configObject:PrettyError.ConfigObject ):PrettyError;
withoutColors():PrettyError;
withColors():PrettyError;
skipPackage( ... packages:string[] ):PrettyError;
unskipPackage( ... packages:string[] ):PrettyError;
unskipAllPackages():PrettyError;
skipPath( ... paths:string[] ):PrettyError;
unskipPath( ... paths:string[] ):PrettyError;
unskipAllPaths():PrettyError;
skip( callbacks:PrettyError.Callback ):PrettyError;
unskip( callbacks:PrettyError.Callback ):PrettyError;
unskipAll():PrettyError;
skipNodeFiles():any;
unskipNodeFiles():any;
filter( callbacks:PrettyError.Callback ):PrettyError;
removeFilter( callbacks:PrettyError.Callback ):PrettyError;
removeAllFilters():PrettyError;
filterParsedError( callbacks:PrettyError.Callback ):PrettyError;
removeParsedErrorFilter( callbacks:PrettyError.Callback ):PrettyError;
removeAllParsedErrorFilters():PrettyError;
setMaxItems( maxItems:number ):PrettyError;
alias( stringOrRx:string, alias:string ):PrettyError;
removeAlias( stringOrRx:string ):PrettyError;
removeAllAliases():PrettyError;
appendStyle( toAppend:Object ):PrettyError;
render( e:PrettyError.ParsedError, logIt?:boolean, useColors?:boolean ):string;
getObject( e:Object ):Object;
start(): PrettyError;
stop(): any;
config(configObject: PrettyError.ConfigObject): PrettyError;
withoutColors(): PrettyError;
withColors(): PrettyError;
skipPackage(...packages: string[]): PrettyError;
unskipPackage(...packages: string[]): PrettyError;
unskipAllPackages(): PrettyError;
skipPath(...paths: string[]): PrettyError;
unskipPath(...paths: string[]): PrettyError;
unskipAllPaths(): PrettyError;
skip(callbacks: PrettyError.Callback): PrettyError;
unskip(callbacks: PrettyError.Callback): PrettyError;
unskipAll(): PrettyError;
skipNodeFiles(): any;
unskipNodeFiles(): any;
filter(callbacks: PrettyError.Callback): PrettyError;
removeFilter(callbacks: PrettyError.Callback): PrettyError;
removeAllFilters(): PrettyError;
filterParsedError(callbacks: PrettyError.Callback): PrettyError;
removeParsedErrorFilter(callbacks: PrettyError.Callback): PrettyError;
removeAllParsedErrorFilters(): PrettyError;
setMaxItems(maxItems: number): PrettyError;
alias(stringOrRx: string, alias: string): PrettyError;
removeAlias(stringOrRx: string): PrettyError;
removeAllAliases(): PrettyError;
appendStyle(toAppend: Object): PrettyError;
render(
e: PrettyError.ParsedError,
logIt?: boolean,
useColors?: boolean
): string;
getObject(e: Object): Object;
}
export = PrettyError;
}

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

// Generated by CoffeeScript 1.8.0
// Generated by CoffeeScript 1.12.7
module.exports = function() {

@@ -3,0 +3,0 @@ return {

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

// Generated by CoffeeScript 1.8.0
// Generated by CoffeeScript 1.12.7
module.exports = ['_debugger.js', '_http_agent.js', '_http_client.js', '_http_common.js', '_http_incoming.js', '_http_outgoing.js', '_http_server.js', '_linklist.js', '_stream_duplex.js', '_stream_passthrough.js', '_stream_readable.js', '_stream_transform.js', '_stream_writable.js', '_tls_legacy.js', '_tls_wrap.js', 'assert.js', 'buffer.js', 'child_process.js', 'cluster.js', 'console.js', 'constants.js', 'crypto.js', 'dgram.js', 'dns.js', 'domain.js', 'events.js', 'freelist.js', 'fs.js', 'http.js', 'https.js', 'module.js', 'net.js', 'os.js', 'path.js', 'punycode.js', 'querystring.js', 'readline.js', 'repl.js', 'smalloc.js', 'stream.js', 'string_decoder.js', 'sys.js', 'timers.js', 'tls.js', 'tty.js', 'url.js', 'util.js', 'vm.js', 'zlib.js', 'node.js'];

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

// Generated by CoffeeScript 1.8.0
var ParsedError, prop, sysPath, _fn, _i, _len, _ref;
// Generated by CoffeeScript 1.12.7
var ParsedError, fn, i, len, prop, ref, sysPath;

@@ -39,8 +39,8 @@ sysPath = require('path');

ParsedError.prototype._parseStack = function() {
var line, message, messageLines, reachedTrace, _i, _len, _ref;
var i, len, line, message, messageLines, reachedTrace, ref;
messageLines = [];
reachedTrace = false;
_ref = this._stack.split('\n');
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
line = _ref[_i];
ref = this._stack.split('\n');
for (i = 0, len = ref.length; i < len; i++) {
line = ref[i];
if (line.trim() === '') {

@@ -235,4 +235,4 @@ continue;

_ref = ['message', 'kind', 'arguments', 'type', 'stack', 'trace', 'wrapper'];
_fn = function() {
ref = ['message', 'kind', 'arguments', 'type', 'stack', 'trace', 'wrapper'];
fn = function() {
var methodName;

@@ -246,5 +246,5 @@ methodName = '_get' + prop[0].toUpperCase() + prop.substr(1, prop.length);

};
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
prop = _ref[_i];
_fn();
for (i = 0, len = ref.length; i < len; i++) {
prop = ref[i];
fn();
}

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

// Generated by CoffeeScript 1.8.0
var ParsedError, PrettyError, RenderKid, array, defaultStyle, instance, nodePaths, object, prop, _fn, _i, _len, _ref, _ref1,
__slice = [].slice,
__indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
// Generated by CoffeeScript 1.12.7
var ParsedError, PrettyError, RenderKid, arrayUtils, defaultStyle, fn, instance, isPlainObject, j, len, merge, nodePaths, prop, ref,
slice = [].slice,
indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
_ref = require('utila'), object = _ref.object, array = _ref.array;
isPlainObject = require('lodash/isPlainObject');

@@ -16,2 +16,50 @@ defaultStyle = require('./defaultStyle');

merge = require('lodash/merge');
arrayUtils = {
pluckByCallback: function(a, cb) {
var index, j, len, removed, value;
if (a.length < 1) {
return a;
}
removed = 0;
for (index = j = 0, len = a.length; j < len; index = ++j) {
value = a[index];
if (cb(value, index)) {
removed++;
continue;
}
if (removed !== 0) {
a[index - removed] = a[index];
}
}
if (removed > 0) {
a.length = a.length - removed;
}
return a;
},
pluckOneItem: function(a, item) {
var index, j, len, reached, value;
if (a.length < 1) {
return a;
}
reached = false;
for (index = j = 0, len = a.length; j < len; index = ++j) {
value = a[index];
if (!reached) {
if (value === item) {
reached = true;
continue;
}
} else {
a[index - 1] = a[index];
}
}
if (reached) {
a.length = a.length - 1;
}
return a;
}
};
instance = null;

@@ -93,3 +141,3 @@

PrettyError.prototype.config = function(c) {
var alias, path, _ref1;
var alias, path, ref;
if (c.skipPackages != null) {

@@ -139,6 +187,6 @@ if (c.skipPackages === false) {

if (c.aliases != null) {
if (object.isBareObject(c.aliases)) {
_ref1 = c.aliases;
for (path in _ref1) {
alias = _ref1[path];
if (isPlainObject(c.aliases)) {
ref = c.aliases;
for (path in ref) {
alias = ref[path];
this.alias(path, alias);

@@ -164,6 +212,6 @@ }

PrettyError.prototype.skipPackage = function() {
var packages, pkg, _i, _len;
packages = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
for (_i = 0, _len = packages.length; _i < _len; _i++) {
pkg = packages[_i];
var j, len, packages, pkg;
packages = 1 <= arguments.length ? slice.call(arguments, 0) : [];
for (j = 0, len = packages.length; j < len; j++) {
pkg = packages[j];
this._packagesToSkip.push(String(pkg));

@@ -175,7 +223,7 @@ }

PrettyError.prototype.unskipPackage = function() {
var packages, pkg, _i, _len;
packages = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
for (_i = 0, _len = packages.length; _i < _len; _i++) {
pkg = packages[_i];
array.pluckOneItem(this._packagesToSkip, pkg);
var j, len, packages, pkg;
packages = 1 <= arguments.length ? slice.call(arguments, 0) : [];
for (j = 0, len = packages.length; j < len; j++) {
pkg = packages[j];
arrayUtils.pluckOneItem(this._packagesToSkip, pkg);
}

@@ -191,6 +239,6 @@ return this;

PrettyError.prototype.skipPath = function() {
var path, paths, _i, _len;
paths = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
for (_i = 0, _len = paths.length; _i < _len; _i++) {
path = paths[_i];
var j, len, path, paths;
paths = 1 <= arguments.length ? slice.call(arguments, 0) : [];
for (j = 0, len = paths.length; j < len; j++) {
path = paths[j];
this._pathsToSkip.push(path);

@@ -202,7 +250,7 @@ }

PrettyError.prototype.unskipPath = function() {
var path, paths, _i, _len;
paths = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
for (_i = 0, _len = paths.length; _i < _len; _i++) {
path = paths[_i];
array.pluckOneItem(this._pathsToSkip, path);
var j, len, path, paths;
paths = 1 <= arguments.length ? slice.call(arguments, 0) : [];
for (j = 0, len = paths.length; j < len; j++) {
path = paths[j];
arrayUtils.pluckOneItem(this._pathsToSkip, path);
}

@@ -218,6 +266,6 @@ return this;

PrettyError.prototype.skip = function() {
var callbacks, cb, _i, _len;
callbacks = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
for (_i = 0, _len = callbacks.length; _i < _len; _i++) {
cb = callbacks[_i];
var callbacks, cb, j, len;
callbacks = 1 <= arguments.length ? slice.call(arguments, 0) : [];
for (j = 0, len = callbacks.length; j < len; j++) {
cb = callbacks[j];
this._skipCallbacks.push(cb);

@@ -229,7 +277,7 @@ }

PrettyError.prototype.unskip = function() {
var callbacks, cb, _i, _len;
callbacks = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
for (_i = 0, _len = callbacks.length; _i < _len; _i++) {
cb = callbacks[_i];
array.pluckOneItem(this._skipCallbacks, cb);
var callbacks, cb, j, len;
callbacks = 1 <= arguments.length ? slice.call(arguments, 0) : [];
for (j = 0, len = callbacks.length; j < len; j++) {
cb = callbacks[j];
arrayUtils.pluckOneItem(this._skipCallbacks, cb);
}

@@ -253,6 +301,6 @@ return this;

PrettyError.prototype.filter = function() {
var callbacks, cb, _i, _len;
callbacks = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
for (_i = 0, _len = callbacks.length; _i < _len; _i++) {
cb = callbacks[_i];
var callbacks, cb, j, len;
callbacks = 1 <= arguments.length ? slice.call(arguments, 0) : [];
for (j = 0, len = callbacks.length; j < len; j++) {
cb = callbacks[j];
this._filterCallbacks.push(cb);

@@ -264,7 +312,7 @@ }

PrettyError.prototype.removeFilter = function() {
var callbacks, cb, _i, _len;
callbacks = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
for (_i = 0, _len = callbacks.length; _i < _len; _i++) {
cb = callbacks[_i];
array.pluckOneItem(this._filterCallbacks, cb);
var callbacks, cb, j, len;
callbacks = 1 <= arguments.length ? slice.call(arguments, 0) : [];
for (j = 0, len = callbacks.length; j < len; j++) {
cb = callbacks[j];
arrayUtils.pluckOneItem(this._filterCallbacks, cb);
}

@@ -280,6 +328,6 @@ return this;

PrettyError.prototype.filterParsedError = function() {
var callbacks, cb, _i, _len;
callbacks = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
for (_i = 0, _len = callbacks.length; _i < _len; _i++) {
cb = callbacks[_i];
var callbacks, cb, j, len;
callbacks = 1 <= arguments.length ? slice.call(arguments, 0) : [];
for (j = 0, len = callbacks.length; j < len; j++) {
cb = callbacks[j];
this._parsedErrorFilters.push(cb);

@@ -291,7 +339,7 @@ }

PrettyError.prototype.removeParsedErrorFilter = function() {
var callbacks, cb, _i, _len;
callbacks = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
for (_i = 0, _len = callbacks.length; _i < _len; _i++) {
cb = callbacks[_i];
array.pluckOneItem(this._parsedErrorFilters, cb);
var callbacks, cb, j, len;
callbacks = 1 <= arguments.length ? slice.call(arguments, 0) : [];
for (j = 0, len = callbacks.length; j < len; j++) {
cb = callbacks[j];
arrayUtils.pluckOneItem(this._parsedErrorFilters, cb);
}

@@ -326,3 +374,3 @@ return this;

PrettyError.prototype.removeAlias = function(stringOrRx) {
array.pluckByCallback(this._aliases, function(pair) {
arrayUtils.pluckByCallback(this._aliases, function(pair) {
return pair.stringOrRx === stringOrRx;

@@ -343,3 +391,3 @@ });

PrettyError.prototype.appendStyle = function(toAppend) {
object.appendOnto(this._style, toAppend);
merge(this._style, toAppend);
this._renderer.style(toAppend);

@@ -370,3 +418,3 @@ return this;

PrettyError.prototype.getObject = function(e) {
var count, header, i, item, obj, traceItems, _i, _len, _ref1;
var count, header, i, item, j, len, obj, ref, traceItems;
if (!(e instanceof ParsedError)) {

@@ -391,5 +439,5 @@ e = new ParsedError(e);

count = -1;
_ref1 = e.trace;
for (i = _i = 0, _len = _ref1.length; _i < _len; i = ++_i) {
item = _ref1[i];
ref = e.trace;
for (i = j = 0, len = ref.length; j < len; i = ++j) {
item = ref[i];
if (item == null) {

@@ -459,14 +507,14 @@ continue;

PrettyError.prototype._skipOrFilter = function(item, itemNumber) {
var cb, modName, pair, _i, _j, _k, _l, _len, _len1, _len2, _len3, _ref1, _ref2, _ref3, _ref4, _ref5, _ref6;
var cb, j, k, l, len, len1, len2, len3, m, modName, pair, ref, ref1, ref2, ref3, ref4, ref5;
if (typeof item === 'object') {
if (_ref1 = item.modName, __indexOf.call(this._packagesToSkip, _ref1) >= 0) {
if (ref = item.modName, indexOf.call(this._packagesToSkip, ref) >= 0) {
return true;
}
if (_ref2 = item.path, __indexOf.call(this._pathsToSkip, _ref2) >= 0) {
if (ref1 = item.path, indexOf.call(this._pathsToSkip, ref1) >= 0) {
return true;
}
_ref3 = item.packages;
for (_i = 0, _len = _ref3.length; _i < _len; _i++) {
modName = _ref3[_i];
if (__indexOf.call(this._packagesToSkip, modName) >= 0) {
ref2 = item.packages;
for (j = 0, len = ref2.length; j < len; j++) {
modName = ref2[j];
if (indexOf.call(this._packagesToSkip, modName) >= 0) {
return true;

@@ -476,5 +524,5 @@ }

if (typeof item.shortenedAddr === 'string') {
_ref4 = this._aliases;
for (_j = 0, _len1 = _ref4.length; _j < _len1; _j++) {
pair = _ref4[_j];
ref3 = this._aliases;
for (k = 0, len1 = ref3.length; k < len1; k++) {
pair = ref3[k];
item.shortenedAddr = item.shortenedAddr.replace(pair.stringOrRx, pair.alias);

@@ -484,5 +532,5 @@ }

}
_ref5 = this._skipCallbacks;
for (_k = 0, _len2 = _ref5.length; _k < _len2; _k++) {
cb = _ref5[_k];
ref4 = this._skipCallbacks;
for (l = 0, len2 = ref4.length; l < len2; l++) {
cb = ref4[l];
if (cb(item, itemNumber) === true) {

@@ -492,5 +540,5 @@ return true;

}
_ref6 = this._filterCallbacks;
for (_l = 0, _len3 = _ref6.length; _l < _len3; _l++) {
cb = _ref6[_l];
ref5 = this._filterCallbacks;
for (m = 0, len3 = ref5.length; m < len3; m++) {
cb = ref5[m];
cb(item, itemNumber);

@@ -502,6 +550,6 @@ }

PrettyError.prototype._applyParsedErrorFiltersOn = function(error) {
var cb, _i, _len, _ref1;
_ref1 = this._parsedErrorFilters;
for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
cb = _ref1[_i];
var cb, j, len, ref;
ref = this._parsedErrorFilters;
for (j = 0, len = ref.length; j < len; j++) {
cb = ref[j];
cb(error);

@@ -515,4 +563,4 @@ }

_ref1 = ['renderer', 'style'];
_fn = function() {
ref = ['renderer', 'style'];
fn = function() {
var methodName;

@@ -524,5 +572,5 @@ methodName = '_get' + prop[0].toUpperCase() + prop.substr(1, prop.length);

};
for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
prop = _ref1[_i];
_fn();
for (j = 0, len = ref.length; j < len; j++) {
prop = ref[j];
fn();
}
{
"name": "pretty-error",
"version": "2.2.0-rc.1",
"version": "3.0.2",
"description": "See nodejs errors with less clutter",

@@ -10,20 +10,18 @@ "main": "./lib/PrettyError.js",

"test:watch": "mocha \"test/**/*.coffee\" --watch",
"compile": "coffee --bare --compile --output ./lib ./src",
"compile:watch": "jitter src lib -b",
"watch": "npm run compile:watch & npm run test:watch",
"winwatch": "start/b npm run compile:watch & npm run test:watch",
"prepublish": "npm run compile"
},
"dependencies": {
"utila": "~0.4",
"renderkid": "^2.0.1"
"lodash": "^4.17.20",
"renderkid": "^2.0.4"
},
"devDependencies": {
"chai": "~1.9.2",
"coffee-script": "~1.8.0",
"chai": "~1.9.2",
"mocha": "~2.0.1",
"jitter": "^1.3.0"
"coffeescript": "^1.12.7",
"jitter": "^1.3.0",
"mocha": "^8.2.0"
},

@@ -30,0 +28,0 @@ "author": "Aria Minaei",

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc