UNPKG

@rbxts/zircon

Version:

<div> <img src="https://i.imgur.com/YgpbX7G.png" align="left" width="128"/> <h1>ZIRCON</h1> <h3>A clean, sleek, runtime debugging console for Roblox</h3> <a href="https://npmjs.com/package/@rbxts/zircon"><img src="https://badge.fury.io

38 lines (37 loc) 1.47 kB
import { ZrEnum } from "@rbxts/zirconium/out/Data/Enum"; import { ZirconEnumItem } from "./ZirconEnumItem"; import { ZirconValidator } from "./ZirconTypeValidator"; export declare type EnumMatchTree<TEnum extends ZirconEnum<any>, K extends string, R> = { [P in K]: (value: ZirconEnumItem<TEnum, P>) => R; }; export interface ZirconEnumValidator<K extends string> extends ZirconValidator<string | number | ZirconEnumItem, ZirconEnumItem<ZirconEnum<K>, K>> { Enum: ZirconEnum<K>; } /** * An extension of the `ZrEnum` class for Zircon */ export declare class ZirconEnum<K extends string> extends ZrEnum { constructor(name: string, members: K[]); /** * Returns whether or not the specified value is an ZirconEnumItem of this type * @returns */ is(value: ZirconEnumItem<any>): value is ZirconEnumItem<ZirconEnum<K>, K>; /** * Gets an enum item value by key * @param key The key */ getItem<TKey extends K>(key: TKey): ZirconEnumItem<ZirconEnum<K>, TKey>; /** * Performs a match against the enum item given, similar to `match` in Rust. * * This also provides `_` for handling values that _don't_ match. * @param value The enum item * @param matches The matches */ match<R>(value: ZirconEnumItem, matches: EnumMatchTree<ZirconEnum<K>, K, R> & { _?: () => R; }): R; getValidator(): ZirconEnumValidator<K>; toString(): string; }