Skip to main content
Module

x/denops_std/function/mod.ts>index

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

Find {expr} in {object} and return its index. See indexof() for using a lambda to select the item.

If {object} is a List return the lowest index where the item has a value equal to {expr}. There is no automatic conversion, so the String "4" is different from the Number 4. And the number 4 is different from the Float 4.0. The value of 'ignorecase' is not used here, case matters as indicated by the {ic} argument.

If {object} is Blob return the lowest index where the byte value is equal to {expr}.

If {start} is given then start looking at the item with index {start} (may be negative for an item relative to the end).

When {ic} is given and it is TRUE, ignore case. Otherwise case must match.

-1 is returned when {expr} is not found in {object}. Example:

:let idx = index(words, "the")
:if index(numbers, 123) >= 0

Can also be used as a method:

GetObject()->index(what)

Parameters

denops: Denops
object: unknown
expr: unknown
optional
start: unknown
optional
ic: unknown

Returns

Promise<number>