kubo-rpc-client
Version:
A client library for the Kubo RPC API
22 lines (19 loc) • 609 B
text/typescript
import { toUrlSearchParams } from '../lib/to-url-search-params.js'
import type { NameAPI } from './index.js'
import type { HTTPRPCClient } from '../lib/core.js'
export function createResolve (client: HTTPRPCClient): NameAPI['resolve'] {
return async function * resolve (path, options = {}) {
const res = await client.post('name/resolve', {
signal: options.signal,
searchParams: toUrlSearchParams({
arg: path,
stream: true,
...options
}),
headers: options.headers
})
for await (const result of res.ndjson()) {
yield result.Path
}
}
}