UNPKG

fast-iterable

Version:

Provides LINQ-like fluent api operations for iterables and async iterables (ES2018+).

32 lines (31 loc) 1.65 kB
/// <reference types="node" /> import { FluentAsyncIterable } from './types'; import { FluentEmitOptions } from './types/base'; import { AnyIterable } from 'augmentative-iterable'; import { EventEmitter } from 'events'; /** * Tranforms an asynchronous iterable into a [[FluentAsyncIterable]]. * @typeparam T The type of the items in the async iterable. * @param iterable The asynchronous iterable instance. * @returns The [[FluentAsyncIterable]] instance. */ declare function fluentAsync<T>(iterable: AnyIterable<T> | PromiseLike<AnyIterable<T>>): FluentAsyncIterable<T>; /** * Transforms an EventEmitter into a [[FluentAsyncIterable]]. * * * **IMPORTANT**: the AsyncIterable created from the EventEmitter is always based on a key event which every * emission generates a new yielded result. The default key event is **'data'**. * * Also, the generated AsyncIterable will be infinite unless an ending event is emitted at some point. * The defaults ending events are **'end'** and **'close'**. So, it's important to have in mind this behavior * to use this feature properly. Operations that requires finiteness to be used may fall into an infinite loop. * * If you need to change the key event or other characteristics, you can do it through the **options** parameter * @typeparam T The type of the items in the created FluentAsyncIterable. * @param emitter The EventEmitter * @param options The EventEmitter options. Optional * @returns The [[FluentAsyncIterable]] instance. */ declare function fluentEmit<T = any>(emitter: EventEmitter, options?: FluentEmitOptions): FluentAsyncIterable<T>; export { fluentAsync, fluentEmit };