UNPKG

warscript

Version:

A typescript library for Warcraft III using Warpack.

30 lines (29 loc) 1.24 kB
/// <reference types="@typescript-to-lua/language-extensions" /> /** @noSelfInFile */ export interface Stream<T> { toArray(): T[]; toSet(): Set<T>; groupingBy<R>(f: (this: void, value: T) => R): Map<R, T[]>; joining(sep: string): string; forEach(f: (this: void, value: T) => any): void; count(): number; findFirst(): T | null; reduce<U>(identity: U, accumulator: (this: void, acc: U, value: T) => U): U; peek(f: (this: void, value: T) => any): Stream<T>; map<S>(f: (this: void, value: T) => S): Stream<S>; flatMap<S>(f: (value: T) => Stream<S>): Stream<S>; } export declare namespace Stream { function of<T>(array: T[]): Stream<T>; function ofReversed<T>(array: T[]): Stream<T>; function ofNullable<T>(element: T | null | undefined): Stream<T>; function range(startInclusive: number, endExclusive: number, step?: number): Stream<number>; function rangeClosed(startInclusive: number, endInclusive: number, step?: number): Stream<number>; } export interface EntryStream<K, V> extends Stream<[K, V]> { invert(): EntryStream<V, K>; toMap(): Map<K, V>; } export declare namespace EntryStream { function of<K, V>(map: Map<K, V> | LuaTable<K & {}, V>): EntryStream<K, V>; }