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

@katis/enum

v0.1.0

Published

A modern non-nominative TypeScript enum library

Readme

@katis/enum

A type-safe, non-nominative enum implementation for TypeScript that provides useful helper methods for working with enum values, labels, and reverse mappings.

Features

  • Type-safe enum creation with full TypeScript support
  • Reverse mapping from values to labels
  • Set of all enum values and labels
  • Value existence checking
  • Support for string, number, and symbol values
  • Enumerable properties for JSON serialization
  • No naming conflicts between enum labels and helper methods

Installation

npm install @katis/enum

Usage

Basic Usage

import { Enum } from '@katis/enum';

// Create an enum
const Color = Enum({
  Red: 'RED',
  Green: 'GREEN',
  Blue: 'BLUE'
});

// Use enum values
const color: typeof Color = Color.Red; // Type-safe: 'RED'
console.log(color); // 'RED'

// Check if a value exists
if (Enum.contains(Color, 'RED')) {
  // Value exists in the enum
}

// Get all values
const allColors = Enum.values(Color); // Set { 'RED', 'GREEN', 'BLUE' }

// Get all labels
const allLabels = Enum.labels(Color); // Set { 'Red', 'Green', 'Blue' }

// Get label for a value
const label = Enum.reversed(Color).get('RED'); // 'Red'

// Join multiple enums
const ExtendedColor = Enum({
  ...Color,
  Yellow: 'YELLOW',
  Purple: 'PURPLE'
});
// ExtendedColor now has all colors from Color plus Yellow and Purple

With Different Value Types

// Number values
const Numbers = Enum({
  One: 1,
  Two: 2,
  Three: 3
});

// Symbol values
const Symbols = Enum({
  One: Symbol('one'),
  Two: Symbol('two'),
  Three: Symbol('three')
});

JSON Serialization

const Color = Enum({
  Red: 'RED',
  Green: 'GREEN',
  Blue: 'BLUE'
});

// Serialize
const json = JSON.stringify(Color);
// '{"Red":"RED","Green":"GREEN","Blue":"BLUE"}'

// Deserialize
const deserialized = Enum(JSON.parse(json));

About Enum Labels

This library intentionally does not provide strictly typed literal types for enum labels. While it would be technically possible (and relatively straightforward) to implement this feature, it's a deliberate design choice based on the following principles:

  1. Separation of Concerns: Enum labels should be used purely for display purposes and debugging. They should not be used for making programmatic decisions in your code.

  2. Maintainability: If you need to change a label for display purposes, you shouldn't have to update type definitions throughout your codebase.

  3. Best Practices: Using enum labels for programmatic decisions can lead to brittle code that's hard to maintain. Instead, you should:

    • Use enum values for programmatic decisions
    • Use labels only for display, logging, or debugging purposes
    • If you need to make decisions based on enum members, use the values directly

Example of what NOT to do:

// ❌ Don't do this
if (Enum.reversed(Color).get(value) === 'Red') {
  // Making decisions based on labels
}

// ✅ Do this instead
if (value === Color.Red) {
  // Making decisions based on values
}

License

MIT