// Type definitions for streamjs 1.5.0 // Project: http://winterbe.github.io/streamjs/ // Definitions by: Bence Eros // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped declare class Stream { static from (elems: T[]): Stream; static from(str: string): Stream; static of(...elems: T[]): Stream; static range (startInclusive: number, endExclusive: number): Stream; static rangeClosed (startInclusive: number, endInclusive: number): Stream; static generate (supplier: Stream.Supplier): Stream; static iterate(seed: T, fn: Stream.Function): Stream; anyMatch(predicate: Stream.Predicate): boolean; anyMatch(regexp: RegExp): boolean; anyMatch(sample: Stream.Sample): boolean; allMatch(predicate: Stream.Predicate): boolean; allMatch(regexp: RegExp): boolean; allMatch(sample: Stream.Sample): boolean; average(): number; average(path: string): number; avg(): number; avg(path: string): number; collect(collector: Stream.Collector): T; count(): number; distinct(): Stream; dropWhile(predicate: Stream.Predicate): Stream; dropWhile(regexp: RegExp): Stream; dropWhile(sample: Stream.Sample): Stream; each(consumer: Stream.Consumer): void; filter(predicate: Stream.Predicate): Stream; filter(regexp: RegExp): Stream; filter(sample: Stream.Sample): Stream; findAny(): Stream.Optional; findFirst(): Stream.Optional; forEach(consumer: Stream.Consumer): void; groupBy(mapper: Stream.Function): Stream.GroupingResult; groupBy(path: string): Stream.GroupingResult; groupingBy(mapper: Stream.Function): Stream.GroupingResult; groupingBy(path: string): Stream.GroupingResult; indexBy(keyMapper: Stream.Function, mergeFunction?: Stream.Accumulator): Stream.Map; map (mapper: Stream.Function): Stream; max(): Stream.Optional; max(comparator: Stream.Comparator): Stream.Optional; max(path: string): Stream.Optional; min(): Stream.Optional; min(comparator: Stream.Comparator): Stream.Optional; min(path: string): Stream.Optional; noneMatch(predicate: (elem: T) => boolean): boolean; noneMatch(regexp: RegExp): boolean; flatMap (mapper: Stream.Function): Stream; iterator(): Stream.Iterator; joining(): string; joining(delimiter: string): string; joining(options: Stream.JoinOptions): string; join(): string; join(delimiter: string): string; join(options: Stream.JoinOptions): string; limit(limit: number): Stream; partitioningBy(predicate: Stream.Predicate): T[][]; partitionBy(predicate: Stream.Predicate): T[][]; partitionBy(sample: Stream.Sample): T[][]; partitioningBy(regexp: RegExp): T[][]; partitionBy(regexp: RegExp): T[][]; partitioningBy(size: number): T[][]; partitionBy(size: number): T[][]; partitioningBy(sample: Stream.Sample): T[][]; peek(consumer: Stream.Consumer): Stream; reduce(identity: T, accumulator: Stream.Accumulator): T; reduce(accumulator: Stream.Accumulator): Stream.Optional; reverse(): Stream; size(): number; sorted(): Stream; sorted(comparator: Stream.Comparator): Stream; sorted(path: string): Stream; sort(): Stream; sort(comparator: Stream.Comparator): Stream; sort(path: string): Stream; shuffle(): Stream; skip(n: number): Stream; slice(begin: number, end: number): Stream; sum(): number; sum(path: string): number; takeWhile(predicate: Stream.Predicate): Stream; takeWhile(regexp: RegExp): Stream; takeWhile(sample: Stream.Sample): Stream; toArray(): T[]; toList(): T[]; toMap(keyMapper: Stream.Function, mergeFunction?: Stream.Accumulator): Stream.Map; toMap(path: string, mergeFunction?: Stream.Accumulator): Stream.Map; } declare namespace Stream { export interface Map { [index: string]: T } export interface Sample { [index: string]: any } export interface Accumulator { (e1: T, e2: T): T; } export interface Collector { supplier: Supplier; accumulator: Stream.Accumulator; finisher: Function; } export interface Comparator { (e1: T, e2: T): number } export interface Consumer { (elem: T): void; } export interface Function { (elem: T): U; } export interface GroupingResult { [index: string]: T } export interface Iterator { next(): T; done: boolean; } export interface JoinOptions { prefix: string; delimiter: string; suffix: string; } export interface Predicate { (elem: T): boolean; } export interface Supplier { (): T } export class Optional { static of(elem: T): Optional; static ofNullable(elem: T): Optional; filter(predicate: (elem: T) => boolean): Optional; map(mapper: (elem: T) => U): Optional; flatMap(mapper: (elem: T) => Stream.Optional): Optional; isPresent(): boolean; get(): T; ifPresent(consumer: (elem: T) => void): void; orElse(other: T): T; orElseGet(supplier: Stream.Supplier): T; orElseThrow(error: any): T; } }