Skip to main content
Home

Built and signed on GitHub Actions

Works with
This package works with Cloudflare Workers, Node.js, Deno, Bun, Browsers
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 Score100%
Downloads96/wk
Published2 years ago (0.1.0)

Check whether values are members of enums.

isEnum

Check whether values are members of enums.

Usage

import { isEnum, makeIsEnum } from "@garretmh/is-enum";

enum Example {
  Foo,
  Bar,
  Baz,
}

// Check if a value is an enum member
if (isEnum(Examples, someValue)) {
  // someValue: Example
}

// Create a dedicate function for checking enum members
const isExample = makeIsEnum(Example);
if (someArray.every(isExample)) {
  // someArray: Example[]
}
Built and signed on
GitHub Actions

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:@garretmh/is-enum

Import symbol

import * as is_enum from "@garretmh/is-enum";
or

Import directly with a jsr specifier

import * as is_enum from "jsr:@garretmh/is-enum";

Add Package

pnpm i jsr:@garretmh/is-enum
or (using pnpm 10.8 or older)
pnpm dlx jsr add @garretmh/is-enum

Import symbol

import * as is_enum from "@garretmh/is-enum";

Add Package

yarn add jsr:@garretmh/is-enum
or (using Yarn 4.8 or older)
yarn dlx jsr add @garretmh/is-enum

Import symbol

import * as is_enum from "@garretmh/is-enum";

Add Package

vlt install jsr:@garretmh/is-enum

Import symbol

import * as is_enum from "@garretmh/is-enum";

Add Package

npx jsr add @garretmh/is-enum

Import symbol

import * as is_enum from "@garretmh/is-enum";

Add Package

bunx jsr add @garretmh/is-enum

Import symbol

import * as is_enum from "@garretmh/is-enum";