Other
This page provides an overview of additional utility functions and types that are exported for use in your application.
import * as util from "#core/util"PermissionsNames Type
The PermissionsNames type represents the keys of the PermissionFlagsBits object from Discord v10, allowing for type-safe permission handling.
export type PermissionsNames = keyof typeof v10.PermissionFlagsBitsdivider Function
divider FunctionThe divider function is used to split an array into smaller sections based on a specified number of items per division.
Type signature:
export function divider<T, Out>(
items: T[],
itemCountByDivision: number,
mapping?: (section: T[], index: number, all: T[][]) => Out,
): T[][] | Promise<Out[]>Example:
const items = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
const dividedItems = await divider(items, 3)whileLoop Function
whileLoop FunctionThe whileLoop function provides a mechanism to execute a loop based on a set of conditions. It continuously calls the iteration function until the conditions are met.
Parameters:
options: An object containing the following properties:resolveValue: A function to resolve the current value.canIterate: A condition function to determine if the loop should continue.iteration: A function to execute on each iteration.after: An optional function to call after the loop finishes.
Source:
scrap Function
scrap FunctionThe scrap function resolves a value that can either be a direct value or a function that returns a value.
Parameters:
item: A resolvable item, either a value or a function....args: Parameters to pass to the function if it is resolvable.
Example:
omit Function
omit FunctionThe omit function creates a new object by excluding specified keys from the original object.
Parameters:
item: The original object from which keys will be omitted....keys: The keys to be omitted.
Example:
pick Function
pick FunctionThe pick function creates a new object by selecting specified keys from the original object.
Parameters:
item: The original object from which keys will be picked....keys: The keys to be picked.
Example:
Last updated
Was this helpful?