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

errs

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

errs - npm Package Compare versions

Comparing version 0.2.0 to 0.2.2

67

lib/errs.js

@@ -18,2 +18,19 @@ /*

//
// Add `Error.prototype.toJSON` if it doesn't exist.
//
if (!Error.prototype.toJSON) {
Object.defineProperty(Error.prototype, 'toJSON', {
enumerable: false,
value: function () {
return mixin({
message: this.message,
stack: this.stack,
arguments: this.arguments,
type: this.type
}, this);
}
});
}
//
// ### function create (type, opts)

@@ -128,7 +145,16 @@ // #### @type {string} **Optional** Registered error type to create

//
// optional stuff that might be created by module
//
Object.keys(err).forEach(function (key) {
merged[key] = err[key];
//
// in node v0.4 v8 errors where treated differently
// we need to make sure we aren't merging these properties
// http://code.google.com/p/v8/issues/detail?id=1215
//
if (['stack', 'type', 'arguments', 'message'].indexOf(key)===-1) {
merged[key] = err[key];
}
});
// merging

@@ -169,3 +195,3 @@ merged.name = merged.name || err.name;

}
if (typeof callback !== 'function' || stream) {

@@ -204,1 +230,36 @@ var emitter = stream || callback || new events.EventEmitter();

};
//
// ### function mixin (target [source0, source1, ...])
// Copies enumerable properties from `source0 ... sourceN`
// onto `target` and returns the resulting object.
//
function mixin(target) {
//
// Quickly and performantly (in V8) `Arrayify` arguments.
//
var len = arguments.length,
args = new Array(len - 1),
i = 1;
for (; i < len; i++) {
args[i - 1] = arguments[i];
}
args.forEach(function (o) {
Object.keys(o).forEach(function (attr) {
var getter = o.__lookupGetter__(attr),
setter = o.__lookupSetter__(attr);
if (!getter && !setter) {
target[attr] = o[attr];
}
else {
if (setter) { target.__defineSetter__(attr, setter) }
if (getter) { target.__defineGetter__(attr, getter) }
}
});
});
return target;
}

26

package.json
{
"name": "errs",
"description": "Simple error creation and passing utilities",
"version": "0.2.0",
"author": "Nodejitsu <info@nodejitsu.com>",
"contributors": [
{ "name": "Charlie Robbins", "email": "charlie@nodejitsu.com" },
{ "name": "Nuno Job", "email": "nuno@nodejitsu.com" }
"version": "0.2.2",
"author": "Nodejitsu Inc. <info@nodejitsu.com>",
"maintainers": [
"indexzero <charlie@nodejitsu.com>",
"dscape <nuno@nodejitsu.com>"
],
"repository": {
"type": "git",
"url": "http://github.com/flatiron/errs.git"
"url": "http://github.com/flatiron/errs.git"
},
"keywords": ["errors", "utilities"],
"keywords": [
"errors",
"utilities"
],
"devDependencies": {

@@ -19,4 +22,9 @@ "vows": "0.6.x"

"main": "./lib/errs",
"scripts": { "test": "vows test/*-test.js --spec" },
"engines": { "node": ">= 0.4.0" }
"scripts": {
"test": "vows test/*-test.js --spec"
},
"engines": {
"node": ">= 0.4.0"
}
}

@@ -134,3 +134,3 @@ /*

var err = new Error('Msg!');
err = errs.merge(err, {message: "Override!", ns: "test"});
err = errs.merge(err, {});
assert.isTrue(Array.isArray(err.stacktrace));

@@ -140,3 +140,3 @@ },

var err = new Error('Msg!');
err = errs.merge(err, {message: "Override!", ns: "test"});
err = errs.merge(err, {message: "Override!"});
assert.equal(err.message, "Override!");

@@ -146,3 +146,3 @@ },

var err = new Error('Msg!');
err = errs.merge(err, {message: "Override!", ns: "test"});
err = errs.merge(err, {ns: "test"});
assert.equal(err.ns, "test");

@@ -152,2 +152,16 @@ }

}
}).addBatch({
"Using errs module": {
"Error.prototype.toJSON": {
"should exist": function () {
assert.isFunction(Error.prototype.toJSON);
var json = (new Error('Testing 12345')).toJSON();
['message', 'stack', 'arguments', 'type'].forEach(function (prop) {
assert.isObject(Object.getOwnPropertyDescriptor(json, prop));
})
}
}
}
}).export(module);
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