Comparing version 1.0.0 to 1.1.0
27
index.js
@@ -97,16 +97,19 @@ 'use strict'; | ||
/** | ||
* Default ErrorCat Instance. | ||
* @type {ErrorCat} | ||
*/ | ||
// Expose default instance methods | ||
var instance = new ErrorCat(); | ||
/** | ||
* Express error responder middleware. | ||
* @type {function} | ||
*/ | ||
Object.defineProperty(ErrorCat, 'middleware', { | ||
value: instance.respond.bind(instance), | ||
writable: false, | ||
enumerable: true | ||
var defaultMethods = { | ||
'middleware': 'respond', | ||
'create': 'create', | ||
'log': 'log', | ||
'report': 'report' | ||
}; | ||
Object.keys(defaultMethods).forEach(function (name) { | ||
Object.defineProperty(ErrorCat, name, { | ||
value: instance[defaultMethods[name]].bind(instance), | ||
writable: false, | ||
enumerable: true | ||
}); | ||
}); |
{ | ||
"name": "error-cat", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"description": "A friendly feline companion that helps you create, track, and report errors.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -5,2 +5,3 @@ # error-cat | ||
[](https://david-dm.org/Runnable/error-cat/dev-status.svg) | ||
[](https://nodei.co/npm/error-cat) | ||
@@ -7,0 +8,0 @@ A friendly feline companion that helps you create errors, track them, and report them via rollbar. |
@@ -30,2 +30,26 @@ 'use strict'; | ||
}); | ||
it('should expose an immutable create method', function(done) { | ||
expect(ErrorCat.create).to.be.a.function(); | ||
expect(function () { | ||
ErrorCat.create = 'something else'; | ||
}).to.throw(); | ||
done(); | ||
}); | ||
it('should expose an immutable log method', function(done) { | ||
expect(ErrorCat.log).to.be.a.function(); | ||
expect(function () { | ||
ErrorCat.log = function () {}; | ||
}).to.throw(); | ||
done(); | ||
}); | ||
it('should expose an immutable report method', function(done) { | ||
expect(ErrorCat.report).to.be.a.function(); | ||
expect(function () { | ||
ErrorCat.report = 22; | ||
}).to.throw(); | ||
done(); | ||
}); | ||
}); // end 'interface' | ||
@@ -32,0 +56,0 @@ |
16081
338
107