Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/ddc_vim/deps.ts>fn.flatten

Dark deno-powered completion framework for neovim/Vim
Go to Latest
function fn.flatten
import { fn } from "https://deno.land/x/ddc_vim@v4.0.2/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[]>