@ackee/antonio-core
Version:
A HTTP client built on fetch API with axios-like API.
25 lines (24 loc) • 748 B
TypeScript
interface OnProgress<T> {
(value: T): Generator<T, void, any>;
}
/**
* Converts async generator to sync generator.
* Use it to handle `iterableStream` response data type.
*
* @example
* ```ts
* import { runIterableStream } from `@ackee/antonio-core`;
*
* function* fetchPosts() {
* const { data } = yield* api.get('/posts', {
* responseDataType: 'iterableStream',
* });
*
* yield runIterableStream(data, function*(slice) {
* console.log(slice) // -> [{ title: '1' }, { title: '2' }, ...]
* });
* }
* ```
*/
export declare function runIterableStream<T = string | any[]>(it: AsyncGenerator<T, void, unknown>, onProgress: OnProgress<T>): Generator<T | Promise<IteratorResult<T, void>>, void, any>;
export {};