Skip to main content
The Deno 2 Release Candidate is here
Learn more
Module

x/collection/src/Collection.ts>default#reduce

Utility data structure for Deno (Discord.js Collection).
Latest
method default.prototype.reduce
import { default } from "https://deno.land/x/collection@v1.0.1/src/Collection.ts";

Applies a function to produce a single value. Identical in behavior to Array.reduce().

Examples

collection.reduce((acc, guild) => acc + guild.memberCount, 0);

Parameters

fn: (
accumulator: T,
value: V,
key: K,
collection: this,
) => T

Function used to reduce, taking four arguments; accumulator, currentValue, currentKey, and collection

optional
initialValue: T