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

x/revoltio/deps.ts>Collection#reduce

No-nonsense Revolt library for nodejs and deno.
Latest
method Collection.prototype.reduce
import { Collection } from "https://deno.land/x/revoltio@v1.0.0/deps.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

Starting value for the accumulator