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 🙏

© 2025 – Pkg Stats / Ryan Hefner

master-enumerator

v1.1.0

Published

Allows users to harness psuedo-enumerator data types

Readme

Master Enumerator

A JavaScript library for psuedo-enums (enumerators)

The Basics

Install:

npm install master-enumerator

Use:

This constructor takes in an array which houses the string enum values, it can also optionally be constructed with a custom properties object (as of right now caseSensitive is the only configurable property) - caseSensitive === true will preserve the value of the string in the array - by default the key AND value will always be uppercase - caseSensitive === false then the value is not manipulated in any way (i.e. with toUpperCase() like in the default scenario).

new Enumerator(array[], options?{ caseSensitive: boolean });

Examples:

No custom options are specified - defaulting caseSensitive = false

const { Enumerator } = require('master-enumerator');

const enumerator = new Enumerator([ 'one', 'two', 'three' ]);

Enumerator {
  getter: ONE() => { return 'ONE' }
  getter: TWO() =>  return 'TWO' }
  getter: THREE() =>  { return 'THREE' }

  enumerations: [
    {
      key: 'ONE',
      value: 'ONE'
    },
    {
      key: 'TWO',
      value: 'TWO'
    },
    {
      key: 'THREE',
      value: 'THREE'
    }
  ]
}

enumerator.ONE // output: 'ONE'
enumerator.TWO // output: 'TWO'
enumerator.THREE // output: 'THREE'

The one custom option is specified - making caseSensitive = true

const { Enumerator } = require('master-enumerator');

const enumerator = new Enumerator([ 'one', 'tWo', 'THREE' ], { caseSensitive: true });

Enumerator {
  getter: ONE() => { return 'one' }
  getter: TWO() =>  return 'tWo' }
  getter: THREE() =>  { return 'THREE' }

  enumerations: [
    {
      key: 'ONE',
      value: 'one'
    },
    {
      key: 'TWO',
      value: 'tWo'
    },
    {
      key: 'THREE',
      value: 'THREE'
    }
  ]
}

enumerator.ONE // output: 'one'
enumerator.TWO // output: 'tWo'
enumerator.THREE // output: 'THREE'

Methods of Enumerator

validValue:

This method allows you to check a string value against your psude-enumerator data type, returning true if the string value is a correlating type of this enumerator and false if it is not.

const enumerator = new Enumerator(array[], options?{ caseSensitive: boolean });

enumerator.validValue('string/value');

Example:

const { Enumerator } = require('master-enumerator');

const enumerator = new Enumerator([ 'one', 'two', 'three' ]);

enumerator.validValue('one'); // output: true
enumerator.validValue('One'); // output: true
enumerator.validValue('ONE'); // output: true
const { Enumerator } = require('master-enumerator');

const enumerator = new Enumerator([ 'one', 'tWo', 'THREE' ], { caseSensitive: true });

enumerator.validValue('tWo'); // output: true
enumerator.validValue('TWO'); // output: false
enumerator.validValue('two'); // output: false

validValues:

This method allows you to check an array of values against your psude-enumerator data type, returning an array with booleans - true if the value in the same exact index location in the passed in array is a correlating type/value of this enumerator and false if it is not.

const enumerator = new Enumerator(array[], options?{ caseSensitive: boolean });

enumerator.validValues(array[]);

Example:

const { Enumerator } = require('master-enumerator');

const enumerator = new Enumerator([ 'one', 'two', 'three' ]);

enumerator.validValues(['one', 'One', 'ONE']); // output: [true, true, true]
const { Enumerator } = require('master-enumerator');

const enumerator = new Enumerator([ 'one', 'two', 'three' ], { caseSensitive: true });

enumerator.validValues(['one', 'One', 'ONE']); // output: [true, false, false]

enumerationKeys():

This method returns the Enumerator's getter keys/properties that are used to get the values behind its enums.

const enumerator = new Enumerator(array[], options?{ caseSensitive: boolean });

enumerator.enumerationKeys();

Example:

const { Enumerator } = require('master-enumerator');

const enumerator = new Enumerator([ 'one', 'two', 'three' ]);

enumerator.enumerationKeys(); // output: [ 'ONE', 'TWO', THREE' ]
const { Enumerator } = require('master-enumerator');

const enumerator = new Enumerator([ 'one', 'tWo', 'TRHEE' ], { caseSensitive: true });

enumerator.enumerationValues(); // output: [ 'ONE', 'TWO', THREE' ]

enumerationValues():

This method returns an array of the Enumerator's values behind its enums/getter keys/properties.

const enumerator = new Enumerator(array[], options?{ caseSensitive: boolean });

enumerator.enumerationValues();

Example:

const { Enumerator } = require('master-enumerator');

const enumerator = new Enumerator([ 'one', 'two', 'three' ]);

enumerator.enumerationValues(); // output: [ 'ONE', 'TWO', THREE' ]
const { Enumerator } = require('master-enumerator');

const enumerator = new Enumerator([ 'one', 'tWo', 'TRHEE' ], { caseSensitive: true });

enumerator.enumerationValues(); // output: [ 'one', 'tWo', THREE' ]

More information

  • The directory test/ contains very thorough TDD and BDD examples/tests.