Skip to main content
Module

x/collections/mod.ts>Vector#reduce

Collection data structures that are not standard built-in objects in JavaScript. This includes a vector (double-ended queue), binary heap (priority queue), binary search tree, and a red black tree.
Very Popular
Latest
method Vector.prototype.reduce
import { Vector } from "https://deno.land/x/collections@0.12.1/mod.ts";

Applies a function against an accumulator and each value of the vector (from left-to-right) to reduce it to a single value. If no initial value is supplied, the first value in the vector will be used and skipped. Calling reduce on an empty array without an initial value creates a TypeError.

Parameters

callback: (
previousValue: U,
currentValue: T,
currentIndex: number,
) => U
optional
initialValue: U