Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

[WIP] feat: ready promise #1878

Closed
wants to merge 2 commits into from
Closed
Changes from 1 commit
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
13 changes: 13 additions & 0 deletions src/core/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,14 @@ class IPFS extends EventEmitter {
}

boot(this)
this.once('ready', () => this.__ready = true)
}
get ready () {
return new Promise((resolve, reject) => {
if (this.__ready) return resolve(this)
this.on('ready', () => resolve(this))
this.on('error', reject)
})
}
}

Expand All @@ -195,3 +203,8 @@ exports = module.exports = IPFS
exports.createNode = (options) => {
return new IPFS(options)
}

exports.create = (options) => {
let node = new IPFS(options)
return node.ready
}