forked from Gozala/ipdf
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.repl.js
More file actions
50 lines (43 loc) · 1.01 KB
/
.repl.js
File metadata and controls
50 lines (43 loc) · 1.01 KB
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
41
42
43
44
45
46
47
48
49
50
// @flow strict
import IPFS from "ipfs"
import Crypto from "./src/crypto.js"
import * as Feed from "./src/feed.js"
import { Dag } from "./src/ipfs.js"
export const ipfs = new IPFS({
EXPERIMENTAL: { pubsub: true, dht: true, ipnsPubsub: true }
})
export const service = { ipfs, crypto: Crypto(ipfs.util.crypto) }
export const wait = promise => {
promise.then(
value => {
console.log((wait.result = promise.result = { ok: true, value }))
},
error => {
console.log((wait.result = promise.result = { ok: false, error }))
}
)
return promise
}
export const callback = (error, value) => {
if (error) {
console.log((callback.result = { ok: false, error }))
} else {
console.log((callback.result = { ok: true, value }))
}
}
const main = async () => {
Object.assign(global, {
wait,
callback,
ipfs,
service,
IPFS,
Crypto,
Feed,
Dag
})
global.feed = await Feed.feed(service)
global.agent = feed.agent
console.log("Feed started", feed)
}
main()