UNPKG

kubo-rpc-client

Version:
31 lines 930 B
import { CID } from 'multiformats/cid'; import { toUrlSearchParams } from '../lib/to-url-search-params.js'; export function createRm(client) { return async function* rm(cid, options = {}) { if (!Array.isArray(cid)) { cid = [cid]; } const res = await client.post('block/rm', { signal: options.signal, searchParams: toUrlSearchParams({ arg: cid.map(cid => cid.toString()), 'stream-channels': true, ...options }), headers: options.headers }); for await (const removed of res.ndjson()) { yield toCoreInterface(removed); } }; } function toCoreInterface(removed) { const out = { cid: CID.parse(removed.Hash) }; if (removed.Error != null) { out.error = new Error(removed.Error); } return out; } //# sourceMappingURL=rm.js.map