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

x/revoltio/deps.ts>Collection#find

No-nonsense Revolt library for nodejs and deno.
Latest
method Collection.prototype.find
import { Collection } from "https://deno.land/x/revoltio@v1.0.0/deps.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');

Type Parameters

V2 extends V

Parameters

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

The function to test with (should return boolean)

Returns

V2 | undefined

Parameters

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

Returns

V | undefined

Type Parameters

This
V2 extends V

Parameters

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

Returns

V2 | undefined

Parameters

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

Returns

V | undefined