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

x/ddu_vim/deps.ts>fn.insert

Dark deno-powered UI framework for neovim/Vim
Go to Latest
function fn.insert
import { fn } from "https://deno.land/x/ddu_vim@v4.0.0/deps.ts";
const { insert } = fn;

When {object} is a List or a Blob insert {item} at the start of it.

If {idx} is specified insert {item} before the item with index {idx}. If {idx} is zero it goes before the first item, just like omitting {idx}. A negative {idx} is also possible, see list-index. -1 inserts just before the last item.

Returns the resulting List or Blob. Examples:

:let mylist = insert([2, 3, 5], 1)
:call insert(mylist, 4, -1)
:call insert(mylist, 6, len(mylist))

The last example can be done simpler with add(). Note that when {item} is a List it is inserted as a single item. Use extend() to concatenate Lists.

Can also be used as a method:

mylist->insert(item)

Parameters

denops: Denops
object: unknown
item: unknown
optional
idx: unknown

Returns

Promise<unknown[]>