geninq
Version:
A JavaScript version of the Linq library for Generators
33 lines (29 loc) • 790 B
text/typescript
import { Build } from "./utils";
declare global {
interface Generator<T = unknown, TReturn = any, TNext = unknown> {
/**
* Converts the sequence into an AsyncGenerator for asynchrones processing.
* @returns A type safe async generator
*/
async(): AsyncGenerator<T, TReturn, TNext>;
}
interface AsyncGenerator<T = unknown, TReturn = any, TNext = unknown> {
/**
* Converts the sequence into an AsyncGenerator for asynchrones processing.
* Present for when you do not know if you sequence is async or not.
* @returns The original subject.
*/
async(): AsyncGenerator<T, TReturn, TNext>;
}
}
Build(
"async",
async function* () {
for (const item of this) {
yield item;
}
},
function () {
return this;
}
);