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

Commit 5de1b13

Browse files
authored
chore: remove streaming iterables (#3888)
It's got some problems when bundling: ``` resolve 'process/browser' in '/Users/alex/Documents/Workspaces/ipfs-examples/js-ipfs-examples/node_modules/streaming-iterables/dist' Parsed request is a module using description file: /Users/alex/Documents/Workspaces/ipfs-examples/js-ipfs-examples/node_modules/streaming-iterables/package.json (relative path: ./dist) Field 'browser' doesn't contain a valid alias configuration ... ```
1 parent 498d9b0 commit 5de1b13

File tree

2 files changed

+24
-19
lines changed

2 files changed

+24
-19
lines changed

packages/ipfs-core/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@
105105
"it-last": "^1.0.4",
106106
"it-map": "^1.0.4",
107107
"it-merge": "^1.0.2",
108+
"it-parallel": "^1.0.0",
108109
"it-peekable": "^1.0.2",
109110
"it-pipe": "^1.1.0",
110111
"it-pushable": "^1.4.2",
@@ -128,7 +129,6 @@
128129
"pako": "^1.0.2",
129130
"parse-duration": "^1.0.0",
130131
"peer-id": "^0.15.1",
131-
"streaming-iterables": "^6.0.0",
132132
"timeout-abort-controller": "^1.1.1",
133133
"uint8arrays": "^3.0.0"
134134
},

packages/ipfs-core/src/components/block/rm.js

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11

22
import errCode from 'err-code'
3-
import { parallelMap, filter } from 'streaming-iterables'
3+
import parallel from 'it-parallel'
4+
import map from 'it-map'
5+
import filter from 'it-filter'
46
import { pipe } from 'it-pipe'
57
import { cleanCid } from './utils.js'
68
import { withTimeoutOption } from 'ipfs-core-utils/with-timeout-option'
@@ -27,30 +29,33 @@ export function createRm ({ repo }) {
2729
try {
2830
yield * pipe(
2931
cids,
30-
parallelMap(BLOCK_RM_CONCURRENCY, async cid => {
31-
cid = cleanCid(cid)
32+
source => map(source, cid => {
33+
return async () => {
34+
cid = cleanCid(cid)
3235

33-
/** @type {import('ipfs-core-types/src/block').RmResult} */
34-
const result = { cid }
36+
/** @type {import('ipfs-core-types/src/block').RmResult} */
37+
const result = { cid }
3538

36-
try {
37-
const has = await repo.blocks.has(cid)
39+
try {
40+
const has = await repo.blocks.has(cid)
3841

39-
if (!has) {
40-
throw errCode(new Error('block not found'), 'ERR_BLOCK_NOT_FOUND')
41-
}
42+
if (!has) {
43+
throw errCode(new Error('block not found'), 'ERR_BLOCK_NOT_FOUND')
44+
}
4245

43-
await repo.blocks.delete(cid)
44-
} catch (/** @type {any} */ err) {
45-
if (!options.force) {
46-
err.message = `cannot remove ${cid}: ${err.message}`
47-
result.error = err
46+
await repo.blocks.delete(cid)
47+
} catch (/** @type {any} */ err) {
48+
if (!options.force) {
49+
err.message = `cannot remove ${cid}: ${err.message}`
50+
result.error = err
51+
}
4852
}
49-
}
5053

51-
return result
54+
return result
55+
}
5256
}),
53-
filter(() => !options.quiet)
57+
source => parallel(source, BLOCK_RM_CONCURRENCY),
58+
source => filter(source, () => !options.quiet)
5459
)
5560
} finally {
5661
release()

0 commit comments

Comments
 (0)