This package has been deprecated

Author message:

this package has been deprecated

gulp-transform-enum

1.0.2 • Public • Published

gulp-transform-enum

A plugin for gulp that will compile Java-style enums down to Javascript. Maps to strings, not integers.

Installation

$ npm install gulp-transform-enum --save-dev

Use case

This plugin will extend the Javascript language with enums like you know them from Java.

Here's the syntax you can now use:

enum Gender {
    MALEFEMALEUNKNOWN
}

This compiles down to the following ES2015 code:

const Gender = {
    MALE: "MALE",
    FEMALE: "FEMALE",
    UNKNOWN: "UNKNOWN"
}

If you're using babel to support experimental class fields, this plugin will also allow you to define static enums inside the body of a class:

class EnumsAreCool extends Something {
 
    static enum Gender {
        MALE, FEMALE, UNKNOWN
    }
 
    //Rest of body here
}

It will compile down to:

class EnumsAreCool extends Something {
 
    static Gender = {
        MALE: "MALE", FEMALE: "FEMALE", UNKNOWN: "UNKNOWN"
    }
 
    //Rest of body here
}

Enums are NOT part of the official ES2015 module spec. Be aware that the syntax this plugin expects isn't and probably never will be officially supported.

Usage

Simply add it to your gulpfile.js:

const ENUM_EXTENSION = require('gulp-transform-enum');
 
    gulp.src("./components/**/*.*")
        .pipe(ENUM_EXTENSION())
        .pipe(gulp.dest(COMPILED_DIRECTORY + "/components"));

License

Copyright (c) 2016 Dlmma IVS. Released under the MIT license.

Readme

Keywords

Package Sidebar

Install

npm i gulp-transform-enum

Weekly Downloads

2

Version

1.0.2

License

MIT

Last publish

Collaborators

  • dev_null