This commit is contained in:
Lukian 2023-06-20 15:28:07 +02:00
parent 68f4b60012
commit 41ae7ff4bd
1010 changed files with 38622 additions and 17071 deletions

View file

@ -1,7 +1,7 @@
/**
* Represents a type that may or may not be a promise
*/
declare type Awaitable<T> = PromiseLike<T> | T;
type Awaitable<T> = PromiseLike<T> | T;
/**
* Lazy is a wrapper around a value that is computed lazily. It is useful for
@ -18,23 +18,57 @@ declare type Awaitable<T> = PromiseLike<T> | T;
declare function lazy<T>(cb: () => T): () => T;
/**
* Yields the numbers in the given range as an array
* Options for creating a range
*/
interface RangeOptions {
/**
* The end of the range (exclusive)
*/
end: number;
/**
* The start of the range (inclusive)
*/
start: number;
/**
* The amount to increment by
*
* @defaultValue `1`
*/
step?: number;
}
/**
* A generator to yield numbers in a given range
*
* @param start - The start of the range
* @param end - The end of the range (inclusive)
* @param step - The amount to increment between each number
* @remarks
* This method is end-exclusive, for example the last number yielded by `range(5)` is 4. If you
* prefer for the end to be included add 1 to the range or `end` option.
* @param range - A number representing the the range to yield (exclusive) or an object with start, end and step
* @example
* Basic range
* ```ts
* range(3, 5); // [3, 4, 5]
* for (const number of range(5)) {
* console.log(number);
* }
* // Prints 0, 1, 2, 3, 4
* ```
* @example
* Range with a step
* ```ts
* range(3, 10, 2); // [3, 5, 7, 9]
* for (const number of range({ start: 3, end: 10, step: 2 })) {
* console.log(number);
* }
* // Prints 3, 5, 7, 9
* ```
*/
declare function range(start: number, end: number, step?: number): number[];
declare function range(range: RangeOptions | number): Generator<number, void, unknown>;
/**
* Calculates the shard id for a given guild id.
*
* @param guildId - The guild id to calculate the shard id for
* @param shardCount - The total number of shards
*/
declare function calculateShardId(guildId: string, shardCount: number): number;
/**
* Represents an object capable of representing itself as a JSON object
@ -73,4 +107,4 @@ interface Equatable<T> {
*/
declare function isEquatable(maybeEquatable: unknown): maybeEquatable is Equatable<unknown>;
export { Awaitable, Equatable, JSONEncodable, isEquatable, isJSONEncodable, lazy, range };
export { Awaitable, Equatable, JSONEncodable, RangeOptions, calculateShardId, isEquatable, isJSONEncodable, lazy, range };