npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@code-fixer-23/enums

v1.0.3

Published

Typed enum factories for immutable string, number, symbol, and labeled enums.

Readme

@code-fixer-23/enums

Typed enum factories for immutable TypeScript-friendly enum objects. Use it when you want property access, literal inference, runtime validation, and label parsing without reaching for TypeScript enum.

Installation

pnpm add @code-fixer-23/enums

Quick Start

import { createEnum, createLabeledEnum, isParseError } from '@code-fixer-23/enums';

const status = createEnum('string', 'draft', 'published');
status.draft;
// 'draft'

const priority = createLabeledEnum({
  low: 'Low',
  high: 'High',
});

const parsedPriority = priority.parse('High');
if (!isParseError(parsedPriority)) {
  parsedPriority;
  // 'high'
}

createEnum(kind, ...names)

Create immutable enum values from member names.

import { createEnum } from '@code-fixer-23/enums';

const color = createEnum('string', 'red', 'blue');
color.red;
// 'red'

const status = createEnum('number', 'pending', 'done');
status.pending;
// 0

const role = createEnum('symbol', 'admin', 'editor');
role.admin;
// Symbol.for('@code-fixer-23/enums/admin')

Kinds

  • string uses each member name as its value.
  • number assigns zero-based numeric values in declaration order.
  • symbol creates global symbols with Symbol.for('@code-fixer-23/enums/<name>').
  • Duplicate member names are rejected.
  • Enum member properties are immutable at runtime.

createLabeledEnum(labels)

Create labeled string enums from caller-provided key/value pairs. The returned enum uses a Proxy so enum values and helper methods are available on the same object.

import {
  ParseError,
  createLabeledEnum,
  isParseError,
} from '@code-fixer-23/enums';

const priority = createLabeledEnum({
  low: 'Low',
  high: 'High',
});

priority.low;
// 'low'

priority.values.low;
// 'low'

priority.labels.high;
// 'High'

const parsedPriority = priority.parse('High');
// 'high'

const missingPriority = priority.parse('Urgent');
if (isParseError(missingPriority)) {
  missingPriority.name;
  // 'ParseError'
}

priority.validate('low');
// true

priority.validate('urgent');
// false

priority.names;
// ['low', 'high']

priority.entries;
// [['low', 'low'], ['high', 'high']]

priority.hasLabel('Low');
// true

priority.labelOf('high');
// 'High'

Labeled enum API

A labeled enum returns:

  • direct enum value properties such as priority.low
  • values: the generated enum values
  • labels: the original label map
  • names: the member names in declaration order
  • entries: [name, value] tuples in declaration order
  • parse(label): returns the matching enum value or a ParseError
  • hasLabel(label): returns true when the label exists
  • labelOf(value): returns the matching label, or undefined
  • validate(value): returns true when the value belongs to the enum
  • Duplicate labels are rejected to keep parsing unambiguous.
  • Reserved helper names such as parse, values, and labels are rejected as enum keys.

Parse errors

Parsing never throws. Instead, parse failures return a ParseError value:

const result = priority.parse('Urgent');

if (result instanceof ParseError) {
  console.log(result.message);
}

Package Format

This package publishes ESM with generated TypeScript declarations:

  • Runtime entrypoint: dist/index.js
  • Type declarations: dist/index.d.ts
  • Package export: @code-fixer-23/enums

Development

pnpm nx typecheck enums
pnpm nx test enums
pnpm nx build enums