0.1.4 • Published 8 years ago

enum-typescript v0.1.4

Weekly downloads
-
License
MIT
Repository
-
Last release
8 years ago

enum-typescript

JavaScript library for enums using Typescript

Installation

enum-typescript can be installed as an npm module

npm install --save enum-typescript

Basic Usage

import Enum from "Enum";

class Animal extends Enum<string> {
  static Dog = Animal.createEnum("Dog");
  static Cat = Animal.createEnum("Cat");

  string() {
    const value = this.value;
    return `I like ${value}.`;
  }
}

// mapping
Animal.valueOf("Dog") == Animal.Dog;
Animal.valueOf("Cat") == Animal.Cat;

// list
Animal.list(); // [Animal.Dog, Animal.Cat]

Lincense

This project is licensed under the terms of the MIT license.

0.1.4

8 years ago

0.1.3

8 years ago

0.1.1

8 years ago

0.1.0

8 years ago