Type of the items to be collected.
Type of the intermediate object used while collecting.
Type of the collected object.
Takes the intermediate object and the current object; and incorporates the current object into the intermediate object.
Transform the intermediate object into the final result.
Creates a new intermediate object.
Generated using TypeDoc
A collector takes all items of a stream and incorporates them into a single object. It does this by first creating an intermediate container (eg. a Set), then processing all items (eg. adding them to the Set), and finally converting the intermediate value to the resulting value (eg. the size of the set).
function toSetT>(): Collector<T, any, Set<T>> { accumulator(intermediate: T[], item: T) { intermediate.push(item); }, supplier(): T[] { return []; }, finisher(intermediate: T[]): Set<T> { return new Set(intermediate); }, }; stream([1,2,3]).map(x => 2*x).collect(toSet());