Skip to content

Commit

Permalink
Tweak callback throw error
Browse files Browse the repository at this point in the history
  • Loading branch information
ziczhu committed Dec 11, 2016
1 parent 36833e8 commit 27383de
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions lib/detect-port.js
Expand Up @@ -7,13 +7,13 @@ module.exports = function() {

const promise = new Promise((resolve, reject) => {
if (!args.length) {
reject('wrong number of arguments');
return reject('wrong number of arguments');
}

const port = parseInt(args[0], 10);

if (isNaN(port)) {
reject(`wrong type of arguments with: '${args[0]}'`);
return reject(`wrong type of arguments with: '${args[0]}'`);
}

const loop = port => {
Expand Down Expand Up @@ -63,9 +63,9 @@ module.exports = function() {
const cb = args[1];

promise.then(data => {
cb.call(this, null, data);
}).catch(err => {
cb.call(this, err);
process.nextTick(cb.bind(null, null, data));
}, err => {
process.nextTick(cb.bind(null, err));
});
} else {
return promise;
Expand Down
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "detect-port",
"version": "1.0.6",
"version": "1.0.7",
"description": "detect available port",
"keywords": [
"detect",
Expand Down

0 comments on commit 27383de

Please sign in to comment.