This package has been deprecated

Author message:

abandoned

nu-enum

1.3.0 • Public • Published

nu-enum

npm version Build Status Codecov Dependency Status

Create enum-like objects in JavaScript.

Install

npm install nu-enum

Usage

nu-enum exposes a single function

Enum(...args: [...String]) => Enum

Creates an enum with properties args.

Enum properties will be an instance of their parent.

import Enum from 'nu-enum';

const RUNFLAGS = Enum('start', 'pause', 'stop');

RUNFLAGS.start instanceof RUNFLAGS // true
RUNFLAGS.pause instanceof RUNFLAGS // true
RUNFLAGS.stop instanceof RUNFLAGS // true

RUNFLAGS.start.toString(); // "start"

Enum properties are unique across enums.

import Enum from 'nu-enum';

const enumA = Enum('same');
const enumB = Enum('same');

enumA.same === enumB.same // false

Enum.add(arg: String) => Void

Add a property to the enum.

import Enum from 'nu-enum';

const ENUM = Enum('one', 'two', 'three');

ENUM.add('four');

ENUM.four instanceof ENUM // true

License

MIT

Readme

Keywords

none

Package Sidebar

Install

npm i nu-enum

Weekly Downloads

0

Version

1.3.0

License

MIT

Last publish

Collaborators

  • npm