Skip to main content
Using Deno in production at your company? Earn free Deno merch.
Give us feedback
Module

x/revoltio/src/util/mod.ts>Collection#findKey

No-nonsense Revolt library for nodejs and deno.
Latest
method Collection.prototype.findKey
import { Collection } from "https://deno.land/x/revoltio@v1.0.0/src/util/mod.ts";

Searches for the key of a single item where the given function returns a truthy value. This behaves like Array.findIndex(), but returns the key rather than the positional index.

Examples

collection.findKey(user => user.username === 'Bob');

Type Parameters

K2 extends K

Parameters

fn: (
value: V,
key: K,
collection: this,
) => key is K2

The function to test with (should return boolean)

Returns

K2 | undefined

Parameters

fn: (
value: V,
key: K,
collection: this,
) => boolean

Returns

K | undefined

Type Parameters

This
K2 extends K

Parameters

fn: (
this: This,
value: V,
key: K,
collection: this,
) => key is K2
thisArg: This

Returns

K2 | undefined

Parameters

fn: (
this: This,
value: V,
key: K,
collection: this,
) => boolean
thisArg: This

Returns

K | undefined