kubo-rpc-client
Version:
A client library for the Kubo RPC API
18 lines • 610 B
JavaScript
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