Skip to main content
Module

x/dpp_vim/deps.ts>fn.flatten

Dark powered plugin manager for Vim/neovim
Latest
function fn.flatten
import { fn } from "https://deno.land/x/dpp_vim@v0.2.0/deps.ts";
const { flatten } = fn;

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[]>