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

x/collection/src/Collection.ts>default#find

Utility data structure for Deno (Discord.js Collection).
Latest
method default.prototype.find
import { default } from "https://deno.land/x/collection@v1.0.1/src/Collection.ts";

Searches for a single item where the given function returns a truthy value. This behaves like Array.find(). All collections used in Discord.js are mapped using their id property, and if you want to find by id you should use the get method. See MDN for details.

Examples

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

Parameters

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

The function to test with (should return boolean)

Returns

V | undefined

Parameters

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

Returns

V | undefined