Skip to main content
Home

Usefull enums used in g43 scope

This package works with Node.js, Deno, Bun, BrowsersIt is unknown whether this package works with Cloudflare Workers
It is unknown whether this package works with Cloudflare Workers
This package works with Node.js
This package works with Deno
This package works with Bun
This package works with Browsers
JSR Score
82%
Published
5 months ago (0.0.9)

license JSR JSR Score

@g43/enums

A collection of TypeScript enums for common programming needs.

Installation

# Using JSR
npx jsr add @g43/enums

# Using Deno
import { Days, Direction4, Keys } from "jsr:@g43/enums";

Features

  • Days: Enum for days of the week
  • Directions: Enums for 2D and 3D directional constants (Direction4, Direction6, Direction7)
  • Keys: Enum for keyboard key codes
  • Origin: Enum for origin positions (top-left, center, etc.)
  • Button: Enum for mouse button types
  • PointerType: Enum for pointer device types
  • HTTP Status Codes: Enum for common HTTP response status codes

Usage

import { Days, Direction4, HttpStatusCodes, Keys } from "@g43/enums";

// Using day constants
const today = Days.MON;
console.log(`Today is ${today}`); // "Today is MON"

// Using directions for movement
function move(direction: Direction4) {
    switch (direction) {
        case Direction4.UP:
            console.log("Moving up");
            break;
        case Direction4.DOWN:
            console.log("Moving down");
            break;
            // Handle other directions...
    }
}

// Handling keyboard input
function handleKeyPress(event: KeyboardEvent) {
    if (event.code === Keys.SPACE) {
        console.log("Space key pressed");
    }
}

// Working with HTTP status codes
function handleResponse(statusCode: number) {
    if (statusCode === HttpStatusCodes.OK) {
        console.log("Request successful");
    } else if (statusCode === HttpStatusCodes.NOT_FOUND) {
        console.log("Resource not found");
    }
}

API Documentation

For detailed API documentation, see the full documentation.

New Ticket: Report package

Please provide a reason for reporting this package. We will review your report and take appropriate action.

Please review the JSR usage policy before submitting a report.

Add Package

deno add jsr:@g43/enums

Import symbol

import * as enums from "@g43/enums";
or

Import directly with a jsr specifier

import * as enums from "jsr:@g43/enums";

Add Package

pnpm i jsr:@g43/enums
or (using pnpm 10.8 or older)
pnpm dlx jsr add @g43/enums

Import symbol

import * as enums from "@g43/enums";

Add Package

yarn add jsr:@g43/enums
or (using Yarn 4.8 or older)
yarn dlx jsr add @g43/enums

Import symbol

import * as enums from "@g43/enums";

Add Package

vlt install jsr:@g43/enums

Import symbol

import * as enums from "@g43/enums";

Add Package

npx jsr add @g43/enums

Import symbol

import * as enums from "@g43/enums";

Add Package

bunx jsr add @g43/enums

Import symbol

import * as enums from "@g43/enums";