fast-iterable
Version:
Provides LINQ-like fluent api operations for iterables and async iterables (ES2018+).
46 lines (45 loc) • 1.74 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.extend = void 0;
const mounters_1 = require("./mounters");
const add_custom_method_1 = require("./add-custom-method");
const _1 = require(".");
const fluent_async_1 = require("./fluent-async");
const sync_handler_1 = require("./sync-handler");
/**
* Used to add custom methods for the next fluent async iterables created
* Is recommendable to also declare the method in the interface so it can be visible to typescript, like this:
* ```ts
* declare module '@codibre/fluent-iterable'{
* interface FluentIterable {
* myCustomMethod<R>(myParams: someType): FluentIterable<R>
* }
* }
* ```
*/
exports.extend = {
/**
* 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)(sync_handler_1.proxyReference, (0, mounters_1.mountIterableFunctions)({ [name]: operation }, _1.fluent));
},
/**
* Add a method that returns another FluentAsyncIterable
* @param name The name of the method
* @param operation The operation to be made
*/
useAsync(name, operation) {
(0, add_custom_method_1.addCustomMethod)(sync_handler_1.proxyReference, (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)(sync_handler_1.proxyReference, { [name]: operation });
},
};