Skip to main content
Using Deno in production at your company? Earn free Deno merch.
Give us feedback
Module

x/revoltio/src/util/mod.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/src/util/mod.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