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

x/revoltio/src/lib.ts>Collection#ensure

No-nonsense Revolt library for nodejs and deno.
Latest
method Collection.prototype.ensure
Re-export
import { Collection } from "https://deno.land/x/revoltio@v1.0.0/src/lib.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