Skip to main content
Module

x/denops_std/function/mod.ts>flatten

📚 Standard module for denops.vim
Go to Latest
function flatten
import { flatten } from "https://deno.land/x/denops_std@v4.1.4/function/mod.ts";

Flatten {list} up to {maxdepth} levels. Without {maxdepth} the result is a |List| without nesting, as if {maxdepth} is a very large number. The {list} is changed in place, use |flattennew()| if you do not want that. In Vim9 script flatten() cannot be used, you must always use |flattennew()|. {maxdepth} means how deep in nested lists changes are made. {list} is not modified when {maxdepth} is 0. {maxdepth} must be positive number. If there is an error the number zero is returned. Example: :echo flatten([1, [2, [3, 4]], 5]) [1, 2, 3, 4, 5] :echo flatten([1, [2, [3, 4]], 5], 1) [1, 2, [3, 4], 5] Can also be used as a |method|: mylist->flatten()

Parameters

denops: Denops
list: unknown
optional
maxdepth: unknown

Returns

Promise<unknown>