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

Commit de01e54

Browse files
author
Alan Shaw
committed
refactor: async iterables
A roundup of the following PRs: * closes #2658 * closes #2660 * closes #2661 * closes #2668 * closes #2674 * closes #2676 * closes #2680 * test fixes and other fix ups --- To allow us to pass the interface tests, the timeout option is now supported in the `object.get` and `refs` APIs. It doesn't actually cancel the operation all the way down the stack, but allows the method call to return when the timeout is reached. https://github.com/ipfs/js-ipfs/pull/2683/files#diff-47300e7ecd8989b6246221de88fc9a3cR170 --- Supersedes #2724 --- resolves #1438 resolves #1061 resolves #2257 resolves #2509 resolves #1670 refs ipfs-inactive/interface-js-ipfs-core#394 BREAKING CHANGE: `IPFS.createNode` removed BREAKING CHANGE: IPFS is not a class that can be instantiated - use `IPFS.create`. An IPFS node instance is not an event emitter. BREAKING CHANGE: Instance `.ready` property removed. Please use `IPFS.create` instead. BREAKING CHANGE: Callbacks are no longer supported on any API methods. Please use a utility such as [`callbackify`](https://www.npmjs.com/package/callbackify) on API methods that return Promises to emulate previous behaviour. BREAKING CHANGE: `PeerId` and `PeerInfo` classes are no longer statically exported from `ipfs-http-client` since they are no longer used internally. BREAKING CHANGE: `pin.add` results now contain a `cid` property (a [CID instance](https://github.com/multiformats/js-cid)) instead of a string `hash` property. BREAKING CHANGE: `pin.ls` now returns an async iterable. BREAKING CHANGE: `pin.ls` results now contain a `cid` property (a [CID instance](https://github.com/multiformats/js-cid)) instead of a string `hash` property. BREAKING CHANGE: `pin.rm` results now contain a `cid` property (a [CID instance](https://github.com/multiformats/js-cid)) instead of a string `hash` property. BREAKING CHANGE: `add` now returns an async iterable. BREAKING CHANGE: `add` results now contain a `cid` property (a [CID instance](https://github.com/multiformats/js-cid)) instead of a string `hash` property. BREAKING CHANGE: `addReadableStream`, `addPullStream` have been removed. BREAKING CHANGE: `ls` now returns an async iterable. BREAKING CHANGE: `ls` results now contain a `cid` property (whose value is a [CID instance](https://github.com/multiformats/js-cid)) instead of a `hash` property. BREAKING CHANGE: `files.readPullStream` and `files.readReadableStream` have been removed. BREAKING CHANGE: `files.read` now returns an async iterable. BREAKING CHANGE: `files.lsPullStream` and `files.lsReadableStream` have been removed. BREAKING CHANGE: `files.ls` now returns an async iterable. BREAKING CHANGE: `files.ls` results now contain a `cid` property (whose value is a [CID instance](https://github.com/multiformats/js-cid)) instead of a `hash` property. BREAKING CHANGE: `files.ls` no longer takes a `long` option (in core) - you will receive all data by default. BREAKING CHANGE: `files.stat` result now contains a `cid` property (whose value is a [CID instance](https://github.com/multiformats/js-cid)) instead of a `hash` property. BREAKING CHANGE: `get` now returns an async iterable. The `content` property value for objects yielded from the iterator is now an async iterable that yields [`BufferList`](https://github.com/rvagg/bl) objects. BREAKING CHANGE: `stats.bw` now returns an async iterable. BREAKING CHANGE: `addFromStream` has been removed. Use `add` instead. BREAKING CHANGE: `addFromFs` has been removed. Please use the exported `globSource` utility and pass the result to `add`. See the [glob source documentation](https://github.com/ipfs/js-ipfs-http-client#glob-source) for more details and an example. BREAKING CHANGE: `addFromURL` has been removed. Please use the exported `urlSource` utility and pass the result to `add`. See the [URL source documentation](https://github.com/ipfs/js-ipfs-http-client#url-source) for more details and an example. BREAKING CHANGE: `name.resolve` now returns an async iterable. It yields increasingly more accurate resolved values as they are discovered until the best value is selected from the quorum of 16. The "best" resolved value is the last item yielded from the iterator. If you are interested only in this best value you could use `it-last` to extract it like so: ```js const last = require('it-last') await last(ipfs.name.resolve('/ipns/QmHash')) ``` BREAKING CHANGE: `block.rm` now returns an async iterable. BREAKING CHANGE: `block.rm` now yields objects of `{ cid: CID, error: Error }`. BREAKING CHANGE: `dht.findProvs`, `dht.provide`, `dht.put` and `dht.query` now all return an async iterable. BREAKING CHANGE: `dht.findPeer`, `dht.findProvs`, `dht.provide`, `dht.put` and `dht.query` now yield/return an object `{ id: CID, addrs: Multiaddr[] }` instead of a `PeerInfo` instance(s). BREAKING CHANGE: `refs` and `refs.local` now return an async iterable. BREAKING CHANGE: `object.data` now returns an async iterable that yields `Buffer` objects. BREAKING CHANGE: `ping` now returns an async iterable. BREAKING CHANGE: `repo.gc` now returns an async iterable. BREAKING CHANGE: `swarm.peers` now returns an array of objects with a `peer` property that is a `CID`, instead of a `PeerId` instance. BREAKING CHANGE: `swarm.addrs` now returns an array of objects `{ id: CID, addrs: Multiaddr[] }` instead of `PeerInfo` instances. BREAKING CHANGE: `block.stat` result now contains a `cid` property (whose value is a [CID instance](https://github.com/multiformats/js-cid)) instead of a `key` property. BREAKING CHANGE: `bitswap.wantlist` now returns an array of [CID](https://github.com/multiformats/js-cid) instances. BREAKING CHANGE: `bitswap.stat` result has changed - `wantlist` and `peers` values are now an array of [CID](https://github.com/multiformats/js-cid) instances. BREAKING CHANGE: the `init` option passed to the IPFS constructor will now not take any initialization steps if it is set to `false`. Previously, the repo would be initialized if it already existed. This is no longer the case. If you wish to initialize a node but only if the repo exists, pass `init: { allowNew: false }` to the constructor. BREAKING CHANGE: removed `file ls` command from the CLI and HTTP API. BREAKING CHANGE: Delegated peer and content routing modules are no longer included as part of core (but are still available if starting a js-ipfs daemon from the command line). If you wish to use delegated routing and are creating your node _programmatically_ in Node.js or the browser you must `npm install libp2p-delegated-content-routing` and/or `npm install libp2p-delegated-peer-routing` and provide configured instances of them in [`options.libp2p`](https://github.com/ipfs/js-ipfs#optionslibp2p). See the module repos for further instructions: - https://github.com/libp2p/js-libp2p-delegated-content-routing - https://github.com/libp2p/js-libp2p-delegated-peer-routing
1 parent bfa1c99 commit de01e54

File tree

201 files changed

+5014
-6152
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

201 files changed

+5014
-6152
lines changed

package.json

+46-76
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@
1515
],
1616
"main": "src/core/index.js",
1717
"browser": {
18-
"./src/core/components/init-assets.js": false,
19-
"./src/core/runtime/add-from-fs-nodejs.js": "./src/core/runtime/add-from-fs-browser.js",
18+
"./src/core/runtime/init-assets-nodejs.js": "./src/core/runtime/init-assets-browser.js",
2019
"./src/core/runtime/config-nodejs.js": "./src/core/runtime/config-browser.js",
2120
"./src/core/runtime/dns-nodejs.js": "./src/core/runtime/dns-browser.js",
2221
"./src/core/runtime/libp2p-nodejs.js": "./src/core/runtime/libp2p-browser.js",
@@ -25,7 +24,8 @@
2524
"./src/core/runtime/repo-nodejs.js": "./src/core/runtime/repo-browser.js",
2625
"./src/core/runtime/ipld-nodejs.js": "./src/core/runtime/ipld-browser.js",
2726
"./test/utils/create-repo-nodejs.js": "./test/utils/create-repo-browser.js",
28-
"stream": "readable-stream"
27+
"stream": "readable-stream",
28+
"ipfs-utils/src/files/glob-source": false
2929
},
3030
"browser-all-ipld-formats": {
3131
"./src/core/runtime/ipld-browser.js": "./src/core/runtime/ipld-browser-all.js"
@@ -65,48 +65,41 @@
6565
"@hapi/hapi": "^18.3.2",
6666
"@hapi/joi": "^15.0.0",
6767
"abort-controller": "^3.0.0",
68+
"any-signal": "^1.1.0",
6869
"array-shuffle": "^1.0.1",
69-
"async-iterator-to-pull-stream": "^1.3.0",
70-
"async-iterator-to-stream": "^1.1.0",
71-
"base32.js": "~0.1.0",
7270
"bignumber.js": "^9.0.0",
7371
"binary-querystring": "~0.1.2",
7472
"bl": "^4.0.0",
7573
"bs58": "^4.0.1",
76-
"buffer-peek-stream": "^1.0.1",
7774
"byteman": "^1.3.5",
78-
"callbackify": "^1.1.0",
7975
"cid-tool": "~0.4.0",
80-
"cids": "~0.7.1",
76+
"cids": "^0.7.2",
8177
"class-is": "^1.1.0",
8278
"dag-cbor-links": "^1.3.2",
8379
"datastore-core": "~0.7.0",
84-
"datastore-pubsub": "^0.2.3",
80+
"datastore-level": "^0.14.1",
81+
"datastore-pubsub": "^0.3.0",
8582
"debug": "^4.1.0",
8683
"dlv": "^1.1.3",
8784
"err-code": "^2.0.0",
88-
"explain-error": "^1.0.4",
8985
"file-type": "^12.0.1",
9086
"fnv1a": "^1.0.1",
91-
"fsm-event": "^2.1.0",
9287
"get-folder-size": "^2.0.0",
93-
"glob": "^7.1.3",
9488
"hapi-pino": "^6.1.0",
9589
"hashlru": "^2.3.0",
96-
"human-to-milliseconds": "^2.0.0",
9790
"interface-datastore": "~0.8.0",
98-
"ipfs-bitswap": "^0.26.2",
91+
"ipfs-bitswap": "github:ipfs/js-ipfs-bitswap#refactor/libp2p-async",
9992
"ipfs-block": "~0.8.1",
10093
"ipfs-block-service": "~0.16.0",
101-
"ipfs-http-client": "^41.0.1",
102-
"ipfs-http-response": "~0.4.0",
103-
"ipfs-mfs": "^0.16.0",
94+
"ipfs-http-client": "github:ipfs/js-ipfs-http-client#refactor/async-iterables2",
95+
"ipfs-http-response": "^0.5.0",
96+
"ipfs-mfs": "^1.0.0",
10497
"ipfs-multipart": "^0.3.0",
10598
"ipfs-repo": "^0.30.0",
10699
"ipfs-unixfs": "^0.3.0",
107100
"ipfs-unixfs-exporter": "^0.41.0",
108101
"ipfs-unixfs-importer": "^0.44.0",
109-
"ipfs-utils": "^0.4.2",
102+
"ipfs-utils": "^0.7.1",
110103
"ipld": "~0.25.0",
111104
"ipld-bitcoin": "~0.3.0",
112105
"ipld-dag-cbor": "~0.15.0",
@@ -115,100 +108,77 @@
115108
"ipld-git": "~0.5.0",
116109
"ipld-raw": "^4.0.0",
117110
"ipld-zcash": "~0.4.0",
118-
"ipns": "^0.6.1",
111+
"ipns": "^0.7.0",
119112
"is-domain-name": "^1.0.1",
120113
"is-ipfs": "~0.6.1",
121-
"is-pull-stream": "~0.0.0",
122-
"is-stream": "^2.0.0",
123-
"iso-url": "~0.4.6",
124114
"it-all": "^1.0.1",
125-
"it-pipe": "^1.0.1",
115+
"it-concat": "^1.0.0",
116+
"it-glob": "0.0.7",
117+
"it-last": "^1.0.1",
118+
"it-pipe": "^1.1.0",
126119
"it-to-stream": "^0.1.1",
120+
"iterable-ndjson": "^1.1.0",
127121
"jsondiffpatch": "~0.3.11",
128122
"just-safe-set": "^2.1.0",
129-
"kind-of": "^6.0.2",
130123
"ky": "^0.15.0",
131124
"ky-universal": "~0.3.0",
132-
"libp2p": "^0.26.2",
133-
"libp2p-bootstrap": "~0.9.3",
134-
"libp2p-crypto": "^0.16.2",
125+
"libp2p": "github:libp2p/js-libp2p#refactor/async-await",
126+
"libp2p-bootstrap": "^0.10.2",
127+
"libp2p-crypto": "^0.17.1",
135128
"libp2p-delegated-content-routing": "^0.4.1",
136-
"libp2p-delegated-peer-routing": "^0.3.1",
137-
"libp2p-floodsub": "^0.18.0",
138-
"libp2p-gossipsub": "~0.0.5",
139-
"libp2p-kad-dht": "~0.16.0",
140-
"libp2p-keychain": "^0.5.4",
141-
"libp2p-mdns": "~0.12.0",
129+
"libp2p-delegated-peer-routing": "^0.4.0",
130+
"libp2p-floodsub": "^0.20.0",
131+
"libp2p-gossipsub": "github:ChainSafe/gossipsub-js#71cb905983b125b50c64a9b75d745dfd7fb8f094",
132+
"libp2p-kad-dht": "^0.18.3",
133+
"libp2p-keychain": "^0.6.0",
134+
"libp2p-mdns": "^0.13.0",
135+
"libp2p-mplex": "^0.9.3",
142136
"libp2p-record": "~0.7.0",
143-
"libp2p-secio": "~0.11.0",
144-
"libp2p-tcp": "^0.13.0",
145-
"libp2p-webrtc-star": "~0.16.0",
146-
"libp2p-websocket-star-multi": "~0.4.3",
147-
"libp2p-websockets": "~0.12.3",
148-
"lodash.flatten": "^4.4.0",
149-
"mafmt": "^6.0.10",
137+
"libp2p-secio": "^0.12.1",
138+
"libp2p-tcp": "^0.14.2",
139+
"libp2p-webrtc-star": "^0.17.0",
140+
"libp2p-websockets": "^0.13.0",
141+
"mafmt": "^7.0.0",
150142
"merge-options": "^2.0.0",
151-
"mime-types": "^2.1.21",
152-
"mkdirp": "~0.5.1",
153143
"mortice": "^2.0.0",
154-
"multiaddr": "^6.1.1",
155-
"multiaddr-to-uri": "^5.0.0",
144+
"multiaddr": "^7.2.1",
145+
"multiaddr-to-uri": "^5.1.0",
156146
"multibase": "~0.6.0",
157147
"multicodec": "^1.0.0",
158148
"multihashes": "~0.4.14",
159149
"multihashing-async": "^0.8.0",
160-
"node-fetch": "^2.3.0",
161-
"p-iteration": "^1.1.8",
150+
"p-defer": "^3.0.0",
162151
"p-queue": "^6.1.0",
163-
"peer-book": "^0.9.1",
164-
"peer-id": "~0.12.2",
165-
"peer-info": "~0.15.1",
152+
"parse-duration": "^0.1.2",
153+
"peer-id": "^0.13.5",
154+
"peer-info": "^0.17.0",
166155
"pretty-bytes": "^5.3.0",
167156
"progress": "^2.0.1",
168-
"promise-nodeify": "^3.0.1",
169-
"promisify-es6": "^1.0.3",
170157
"protons": "^1.0.1",
171-
"pull-abortable": "^4.1.1",
172-
"pull-cat": "^1.1.11",
173-
"pull-defer": "~0.2.3",
174-
"pull-file": "^1.1.0",
175-
"pull-mplex": "~0.1.1",
176-
"pull-ndjson": "^0.2.0",
177-
"pull-pushable": "^2.2.0",
178-
"pull-sort": "^1.0.1",
179-
"pull-stream": "^3.6.14",
180-
"pull-stream-to-async-iterator": "^1.0.2",
181-
"pull-stream-to-stream": "^2.0.0",
182-
"pull-traverse": "^1.0.3",
183-
"readable-stream": "^3.4.0",
184-
"receptacle": "^1.3.2",
185158
"semver": "^6.3.0",
186-
"stream-to-pull-stream": "^1.7.3",
187-
"superstruct": "~0.6.2",
159+
"stream-to-it": "^0.2.0",
160+
"streaming-iterables": "^4.1.1",
188161
"tar-stream": "^2.0.0",
189162
"temp": "~0.9.0",
163+
"timeout-abort-controller": "^1.1.0",
190164
"update-notifier": "^4.0.0",
191-
"uri-to-multiaddr": "^3.0.1",
165+
"uri-to-multiaddr": "^3.0.2",
192166
"varint": "^5.0.0",
193167
"yargs": "^15.0.1",
194168
"yargs-promise": "^1.1.0"
195169
},
196170
"devDependencies": {
197171
"aegir": "^20.4.1",
198-
"async": "^2.6.3",
199172
"base64url": "^3.0.1",
200173
"clear-module": "^4.0.0",
201174
"delay": "^4.1.0",
202-
"detect-node": "^2.0.4",
203175
"dir-compare": "^1.7.3",
204176
"execa": "^3.0.0",
205177
"form-data": "^3.0.0",
206178
"hat": "0.0.3",
207-
"interface-ipfs-core": "^0.128.0",
208-
"ipfs-interop": "^0.2.0",
209-
"ipfsd-ctl": "^1.0.2",
210-
"libp2p-websocket-star": "~0.10.2",
211-
"lodash": "^4.17.15",
179+
"interface-ipfs-core": "github:ipfs/interface-js-ipfs-core#refactor/async-iterables",
180+
"ipfs-interop": "github:ipfs/interop#refactor/async-await",
181+
"ipfsd-ctl": "github:ipfs/js-ipfsd-ctl#feat/force-kill",
212182
"ncp": "^2.0.0",
213183
"p-event": "^4.1.0",
214184
"p-map": "^3.0.0",

src/cli/bin.js

+2-18
Original file line numberDiff line numberDiff line change
@@ -37,38 +37,22 @@ updateNotifier({ pkg, updateCheckInterval: oneWeek }).notify()
3737

3838
const cli = new YargsPromise(parser)
3939

40-
let getIpfs = null
41-
4240
// Apply command aliasing (eg `refs local` -> `refs-local`)
4341
const args = commandAlias(process.argv.slice(2))
4442
cli
4543
.parse(args)
4644
.then(({ data, argv }) => {
47-
getIpfs = argv.getIpfs
4845
if (data) {
4946
print(data)
5047
}
5148
})
5249
.catch(({ error, argv }) => {
53-
getIpfs = argv && argv.getIpfs
54-
5550
if (error.code === InvalidRepoVersionError.code) {
5651
error.message = 'Incompatible repo version. Migration needed. Pass --migrate for automatic migration'
5752
}
5853

59-
if (error.message) {
60-
print(error.message)
61-
debug(error)
62-
} else {
63-
print('Unknown error, please re-run the command with DEBUG=ipfs:cli to see debug output')
64-
debug(error)
65-
}
54+
print(error.message || 'Unknown error, please re-run the command with DEBUG=ipfs:cli to see debug output')
55+
debug(error)
6656

6757
process.exit(1)
6858
})
69-
.finally(() => {
70-
if (getIpfs && getIpfs.instance) {
71-
const cleanup = getIpfs.rest[0]
72-
return cleanup()
73-
}
74-
})

src/cli/commands/add.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict'
22

3-
const promisify = require('promisify-es6')
3+
const { promisify } = require('util')
44
const getFolderSize = promisify(require('get-folder-size'))
55
const byteman = require('byteman')
66
const mh = require('multihashes')
@@ -238,20 +238,20 @@ module.exports = {
238238
})
239239
: argv.getStdin() // Pipe directly to ipfs.add
240240

241-
let finalHash
241+
let finalCid
242242

243243
try {
244-
for await (const file of ipfs._addAsyncIterator(source, options)) {
244+
for await (const file of ipfs.add(source, options)) {
245245
if (argv.silent) {
246246
continue
247247
}
248248

249249
if (argv.quieter) {
250-
finalHash = file.hash
250+
finalCid = file.cid
251251
continue
252252
}
253253

254-
const cid = cidToString(file.hash, { base: argv.cidBase })
254+
const cid = cidToString(file.cid, { base: argv.cidBase })
255255
let message = cid
256256

257257
if (!argv.quiet) {
@@ -266,7 +266,7 @@ module.exports = {
266266
bar.terminate()
267267
}
268268

269-
// Tweak the error message and add more relevant infor for the CLI
269+
// Tweak the error message and add more relevant info for the CLI
270270
if (err.code === 'ERR_DIR_NON_RECURSIVE') {
271271
err.message = `'${err.path}' is a directory, use the '-r' flag to specify directories`
272272
}
@@ -279,7 +279,7 @@ module.exports = {
279279
}
280280

281281
if (argv.quieter) {
282-
log(cidToString(finalHash, { base: argv.cidBase }))
282+
log(cidToString(finalCid, { base: argv.cidBase }))
283283
}
284284
})())
285285
}

src/cli/commands/bitswap/stat.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ module.exports = {
3535
stats.dupDataReceived = prettyBytes(stats.dupDataReceived.toNumber()).toUpperCase()
3636
stats.wantlist = `[${stats.wantlist.length} keys]`
3737
} else {
38-
const wantlist = stats.wantlist.map((elem) => cidToString(elem['/'], { base: cidBase, upgrade: false }))
38+
const wantlist = stats.wantlist.map(cid => cidToString(cid, { base: cidBase, upgrade: false }))
3939
stats.wantlist = `[${wantlist.length} keys]
4040
${wantlist.join('\n ')}`
4141
}

src/cli/commands/bitswap/wantlist.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ module.exports = {
2525
resolve((async () => {
2626
const ipfs = await getIpfs()
2727
const list = await ipfs.bitswap.wantlist(peer)
28-
list.Keys.forEach(k => print(cidToString(k['/'], { base: cidBase, upgrade: false })))
28+
list.forEach(cid => print(cidToString(cid, { base: cidBase, upgrade: false })))
2929
})())
3030
}
3131
}

src/cli/commands/block/put.js

+3-9
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
'use strict'
22

3-
const bl = require('bl')
43
const fs = require('fs')
54
const multibase = require('multibase')
6-
const promisify = require('promisify-es6')
5+
const concat = require('it-concat')
76
const { cidToString } = require('../../../utils/cid')
87

98
module.exports = {
@@ -41,14 +40,9 @@ module.exports = {
4140
let data
4241

4342
if (argv.block) {
44-
data = await promisify(fs.readFile)(argv.block)
43+
data = await fs.readFileSync(argv.block)
4544
} else {
46-
data = await new Promise((resolve, reject) => {
47-
argv.getStdin().pipe(bl((err, input) => {
48-
if (err) return reject(err)
49-
resolve(input)
50-
}))
51-
})
45+
data = (await concat(argv.getStdin())).slice()
5246
}
5347

5448
const ipfs = await argv.getIpfs()

src/cli/commands/block/rm.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ module.exports = {
2525
const ipfs = await getIpfs()
2626
let errored = false
2727

28-
for await (const result of ipfs.block._rmAsyncIterator(hash, {
28+
for await (const result of ipfs.block.rm(hash, {
2929
force,
3030
quiet
3131
})) {
@@ -34,7 +34,7 @@ module.exports = {
3434
}
3535

3636
if (!quiet) {
37-
print(result.error || 'removed ' + result.hash)
37+
print(result.error ? result.error.message : `removed ${result.cid}`)
3838
}
3939
}
4040

src/cli/commands/block/stat.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ module.exports = {
2020
resolve((async () => {
2121
const ipfs = await getIpfs()
2222
const stats = await ipfs.block.stat(key)
23-
print('Key: ' + cidToString(stats.key, { base: cidBase }))
23+
print('Key: ' + cidToString(stats.cid, { base: cidBase }))
2424
print('Size: ' + stats.size)
2525
})())
2626
}

src/cli/commands/cat.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ module.exports = {
2222
resolve((async () => {
2323
const ipfs = await getIpfs()
2424

25-
for await (const buf of ipfs._catAsyncIterator(ipfsPath, { offset, length })) {
25+
for await (const buf of ipfs.cat(ipfsPath, { offset, length })) {
2626
process.stdout.write(buf)
2727
}
2828
})())

0 commit comments

Comments
 (0)