Skip to content

Commit

Permalink
ref: use native promises instead of the 'async' lib
Browse files Browse the repository at this point in the history
  • Loading branch information
coolaj86 committed Jun 15, 2023
1 parent 410ff21 commit b94b291
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 17 deletions.
14 changes: 10 additions & 4 deletions lib/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/* eslint-disable */

const promisify = require('util').promisify;
const http = require('http');
const https = require('https');
const async = require('async');

function RpcClient(opts) {
opts = opts || {};
Expand All @@ -25,9 +25,15 @@ function RpcClient(opts) {
this.log = RpcClient.loggers[RpcClient.config.logger || 'normal'];
}

this.queue = async.queue((task, callback) => {
task(callback);
}, queueSize);
this._chain = Promise.resolve();
this.queue = {
push: function (task) {
const taskAsync = promisify(task);
this._chain = this._chain.then(async function () {
await taskAsync();
});
},
};
}

const cl = console.log.bind(console);
Expand Down
13 changes: 1 addition & 12 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
"coverage": "nyc npm run test"
},
"dependencies": {
"async": "^3.2.4",
"bluebird": "^3.7.2"
},
"devDependencies": {
Expand Down

0 comments on commit b94b291

Please sign in to comment.