UNPKG

fast-iterable

Version:

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

35 lines (34 loc) 1.35 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.extendAsync = void 0; const mounters_1 = require("./mounters"); const add_custom_method_1 = require("./add-custom-method"); const fluent_async_1 = require("./fluent-async"); const async_handler_1 = require("./async-handler"); /** * Used to add custom methods for the next fluent async iterables created * Is recommendable to also declare the method in the interface namespace so it can be visible to typescript, like this: * ```ts * declare namespace FluentAsyncIterable { * myCustomMethod<R>(myParams: someType): FluentAsyncIterable<R> * } * ``` */ exports.extendAsync = { /** * Add a method that returns another FluentAsyncIterable * @param name The name of the method * @param operation The operation to be made */ use(name, operation) { (0, add_custom_method_1.addCustomMethod)(async_handler_1.asyncProxyReference, (0, mounters_1.mountIterableFunctions)({ [name]: operation }, fluent_async_1.fluentAsync)); }, /** * Add a resolving method * @param name The name of the method * @param operation The resolving operation to be made */ useResolving(name, operation) { (0, add_custom_method_1.addCustomMethod)(async_handler_1.asyncProxyReference, { [name]: operation }); }, };