Skip to content

Commit

Permalink
Merge pull request #57 from ralphtheninja/zalgo
Browse files Browse the repository at this point in the history
callback on nextTick to avoid zalgo
  • Loading branch information
dignifiedquire committed Feb 18, 2016
2 parents e58ed01 + 9cc1c4d commit 957b620
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ module.exports = {
join(process.env.HOME ||
process.env.USERPROFILE, '.ipfs')
}
done(null, new Node(path))
process.nextTick(() => {
done(null, new Node(path))
})
},
disposableApi (opts, done) {
if (typeof opts === 'function') {
Expand All @@ -29,10 +31,7 @@ module.exports = {
}
this.disposable(opts, (err, node) => {
if (err) return done(err)
node.startDaemon((err, api) => {
if (err) return done(err)
done(null, api)
})
node.startDaemon(done)
})
},
disposable (opts, done) {
Expand All @@ -46,13 +45,12 @@ module.exports = {
const node = new Node(opts.repoPath || tempDir(), opts, true)

if (typeof opts.init === 'boolean' && opts.init === false) {
done(null, node)
process.nextTick(() => {
done(null, node)
})
} else {
node.init(err => {
if (err) {
return done(err)
}
done(null, node)
done(err, node)
})
}
}
Expand Down

0 comments on commit 957b620

Please sign in to comment.