Comparing version 1.4.0 to 1.4.1
11
index.js
@@ -1,11 +0,10 @@ | ||
var debug = function(err) { | ||
var debug = function (err) { | ||
if (process.env.DEBUG) | ||
// eslint-disable-next-line no-console | ||
console.info('Caught error', err, err.stack); | ||
}; | ||
module.exports = function(cb) { | ||
return function(fn) { | ||
return function() { | ||
module.exports = function (cb) { | ||
return function (fn) { | ||
return function () { | ||
var err = arguments[0], | ||
@@ -12,0 +11,0 @@ args = 2 <= arguments.length ? [].slice.call(arguments, 1) : []; |
{ | ||
"name": "cbw", | ||
"version": "1.4.0", | ||
"version": "1.4.1", | ||
"description": "callback wrapper", | ||
"main": "index.js", | ||
"scripts": { | ||
"format": "prettier ''**/*.js' --write", | ||
"lint:eslint": "eslint '**/*.js'", | ||
"lint:prettier": "prettier '**/*.js' --check", | ||
"lint": "npm run lint:eslint && npm run lint:prettier", | ||
"test": "mocha -R spec", | ||
@@ -22,3 +26,7 @@ "postversion": "git push -u origin $(git rev-parse --abbrev-ref HEAD) --follow-tags && npm publish && echo '…released.'", | ||
"devDependencies": { | ||
"mocha": "^10.7.3" | ||
"eslint": "^9.19.0", | ||
"eslint-config-adslot": "^2.0.2", | ||
"globals": "^15.14.0", | ||
"mocha": "^11.0.1", | ||
"prettier": "^3.4.2" | ||
}, | ||
@@ -29,2 +37,8 @@ "repository": { | ||
}, | ||
"prettier": { | ||
"singleQuote": true, | ||
"trailingComma": "es5", | ||
"arrowParens": "always", | ||
"printWidth": 120 | ||
}, | ||
"engines": { | ||
@@ -31,0 +45,0 @@ "node": "^22" |
var assert = require('assert'); | ||
var cbw = require('../index'); | ||
describe('index', function() { | ||
it('should handle error', function(done) { | ||
var async = function(cb) { | ||
describe('index', function () { | ||
it('should handle error', function (done) { | ||
var async = function (cb) { | ||
cb(new Error('oops')); | ||
}; | ||
var handler = function(err) { | ||
var handler = function (err) { | ||
assert.equal(err.message, 'oops'); | ||
@@ -17,24 +15,27 @@ done(); | ||
async(cbw(handler)(function() { | ||
done(new Error('should not reach here')); | ||
})); | ||
async( | ||
cbw(handler)(function () { | ||
done(new Error('should not reach here')); | ||
}) | ||
); | ||
}); | ||
it('should handle result', function(done) { | ||
var async = function(cb) { | ||
it('should handle result', function (done) { | ||
var async = function (cb) { | ||
cb(null, 'one', 2, false); | ||
}; | ||
var handler = function(err) { | ||
var handler = function (_err) { | ||
done(new Error('should not reach here')); | ||
}; | ||
async(cbw(handler)(function(one, two, three) { | ||
assert.equal(one, 'one'); | ||
assert.equal(two, 2); | ||
assert.equal(three, false); | ||
done() | ||
})) | ||
}) | ||
}) | ||
async( | ||
cbw(handler)(function (one, two, three) { | ||
assert.equal(one, 'one'); | ||
assert.equal(two, 2); | ||
assert.equal(three, false); | ||
done(); | ||
}) | ||
); | ||
}); | ||
}); |
Sorry, the diff of this file is not supported yet
7955
10
62
5