Skip to content
This repository has been archived by the owner on Aug 24, 2021. It is now read-only.

use process.nextTick instead of setImmediate #35

Merged
merged 1 commit into from
Jan 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
"url": "https://github.com/multiformats/js-multihashing-async/issues"
},
"dependencies": {
"async": "^2.6.1",
"blakejs": "^1.1.0",
"js-sha3": "^0.7.0",
"multihashes": "~0.4.13",
Expand All @@ -63,6 +62,7 @@
"Harlan T Wood <[email protected]>",
"Juan Batiz-Benet <[email protected]>",
"Marcin Rataj <[email protected]>",
"Matteo Collina <[email protected]>",
"Mitar <[email protected]>",
"Pedro Teixeira <[email protected]>",
"Richard Littauer <[email protected]>",
Expand Down
10 changes: 2 additions & 8 deletions src/utils.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,16 @@
'use strict'

const setImmediate = require('async/setImmediate')

exports.toCallback = (doWork) => {
return function (input, callback) {
const done = (err, res) => setImmediate(() => {
callback(err, res)
})

let res
try {
res = doWork(input)
} catch (err) {
done(err)
process.nextTick(callback, err)
return
}

done(null, res)
process.nextTick(callback, null, res)
}
}

Expand Down