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

x/revoltio/deps.ts>Collection#ensure

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

Obtains the value of the given key if it exists, otherwise sets and returns the value provided by the default value generator.

Examples

collection.ensure(guildId, () => defaultGuildConfig);

Parameters

key: K

The key to get if it exists, or set otherwise

defaultValueGenerator: (key: K, collection: this) => V

A function that generates the default value