Skip to main content
Deno 2 is finally here ๐ŸŽ‰๏ธ
Learn more
Module

x/denops_std/function/vim/mod.ts>reduce

๐Ÿ“š Standard module for denops.vim
Go to Latest
function reduce
import { reduce } from "https://deno.land/x/denops_std@v3.6.0/function/vim/mod.ts";

{func} is called for every item in {object}, which can be a |List| or a |Blob|. {func} is called with two arguments: the result so far and current item. After processing all items the result is returned. {initial} is the initial result. When omitted, the first item in {object} is used and {func} is first called for the second item. If {initial} is not given and {object} is empty no result can be computed, an E998 error is given. Examples: echo reduce([1, 3, 5], { acc, val -> acc + val }) echo reduce(['x', 'y'], { acc, val -> acc .. val }, 'a') echo reduce(0z1122, { acc, val -> 2 * acc + val }) Can also be used as a |method|: echo mylist->reduce({ acc, val -> acc + val }, 0)

Parameters

denops: Denops
object: unknown
func: unknown
optional
initial: unknown

Returns

Promise<unknown>