Skip to main content
The Deno 2 Release Candidate is here
Learn more
Module

x/collection/src/Collection.ts>Collection#findKey

Utility data structure for Deno (Discord.js Collection).
Latest
method Collection.prototype.findKey
import { Collection } from "https://deno.land/x/collection@v1.0.1/src/Collection.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');

Parameters

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

The function to test with (should return boolean)

Returns

K | undefined

Parameters

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

Returns

K | undefined