-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathindex.js
40 lines (31 loc) · 927 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
const { NanoresourcePromise: Nanoresource } = require('nanoresource-promise/emitter')
const HyperspaceClient = require('hyperspace/client')
const Peersockets = require('peersockets')
const DriveClient = require('./lib/clients/drive')
const PeersClient = require('./lib/clients/peers')
class HyperdriveClient extends Nanoresource {
constructor (opts = {}) {
super()
this.opts = opts
this._client = opts.client || new HyperspaceClient({
host: this.opts.host || this.opts.endpoint,
...this.opts
})
this.drive = new DriveClient(this._client)
this.peersockets = new Peersockets(this._client.network)
this.peers = new PeersClient(this._client)
}
ready (cb) {
return this.open(cb)
}
_open () {
return this._client.ready()
}
_close () {
return this._client.close()
}
status (cb) {
return this._client.status(cb)
}
}
module.exports = HyperdriveClient