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

Commit

Permalink
chore: remove streaming iterables (#3888)
Browse files Browse the repository at this point in the history
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
...
```
  • Loading branch information
achingbrain committed Sep 23, 2021
1 parent 498d9b0 commit 5de1b13
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 19 deletions.
2 changes: 1 addition & 1 deletion packages/ipfs-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@
"it-last": "^1.0.4",
"it-map": "^1.0.4",
"it-merge": "^1.0.2",
"it-parallel": "^1.0.0",
"it-peekable": "^1.0.2",
"it-pipe": "^1.1.0",
"it-pushable": "^1.4.2",
Expand All @@ -128,7 +129,6 @@
"pako": "^1.0.2",
"parse-duration": "^1.0.0",
"peer-id": "^0.15.1",
"streaming-iterables": "^6.0.0",
"timeout-abort-controller": "^1.1.1",
"uint8arrays": "^3.0.0"
},
Expand Down
41 changes: 23 additions & 18 deletions packages/ipfs-core/src/components/block/rm.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@

import errCode from 'err-code'
import { parallelMap, filter } from 'streaming-iterables'
import parallel from 'it-parallel'
import map from 'it-map'
import filter from 'it-filter'
import { pipe } from 'it-pipe'
import { cleanCid } from './utils.js'
import { withTimeoutOption } from 'ipfs-core-utils/with-timeout-option'
Expand All @@ -27,30 +29,33 @@ export function createRm ({ repo }) {
try {
yield * pipe(
cids,
parallelMap(BLOCK_RM_CONCURRENCY, async cid => {
cid = cleanCid(cid)
source => map(source, cid => {
return async () => {
cid = cleanCid(cid)

/** @type {import('ipfs-core-types/src/block').RmResult} */
const result = { cid }
/** @type {import('ipfs-core-types/src/block').RmResult} */
const result = { cid }

try {
const has = await repo.blocks.has(cid)
try {
const has = await repo.blocks.has(cid)

if (!has) {
throw errCode(new Error('block not found'), 'ERR_BLOCK_NOT_FOUND')
}
if (!has) {
throw errCode(new Error('block not found'), 'ERR_BLOCK_NOT_FOUND')
}

await repo.blocks.delete(cid)
} catch (/** @type {any} */ err) {
if (!options.force) {
err.message = `cannot remove ${cid}: ${err.message}`
result.error = err
await repo.blocks.delete(cid)
} catch (/** @type {any} */ err) {
if (!options.force) {
err.message = `cannot remove ${cid}: ${err.message}`
result.error = err
}
}
}

return result
return result
}
}),
filter(() => !options.quiet)
source => parallel(source, BLOCK_RM_CONCURRENCY),
source => filter(source, () => !options.quiet)
)
} finally {
release()
Expand Down

0 comments on commit 5de1b13

Please sign in to comment.