UNPKG

kubo-rpc-client

Version:
18 lines 610 B
import { toUrlSearchParams } from '../lib/to-url-search-params.js'; import { mapEvent } from './map-event.js'; export function createQuery(client) { return async function* query(peerId, options = {}) { const res = await client.post('dht/query', { signal: options.signal, searchParams: toUrlSearchParams({ arg: peerId.toString(), ...options }), headers: options.headers }); for await (const event of res.ndjson()) { yield mapEvent(event); } }; } //# sourceMappingURL=query.js.map