1.0.1 • Published 8 years ago
gulp-transform-interface v1.0.1
gulp-transform-interface
A plugin for gulp that will compile Java-style interfaces to Javascript.
Installation
$ npm install gulp-transform-interface --save-dev
Use case
This plugin will extend the Javascript language with interface declarations like you know them from Java.
Here's the syntax you can now use:
interface FooBar {
isFoo = Boolean;
barCollection = Map;
sayFoo(arg1, arg2);
doBar();
}
This compiles down to the following ES2015 code:
const FooBar = {
isFoo: Boolean,
barCollection: Map,
sayFoo(arg1, arg2){},
doBar(){}
}
Combining this with the npm package gulp-class-implements-polymerjs
gives the possibility for declaratively implementing interfaces by
supporting the Java-inspired class <subclass> extends <class> implements <interface>
syntax.
interfaces 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 INTERFACE_EXTENSION = require('gulp-transform-interface');
gulp.src("./components/**/*.*")
.pipe(INTERFACE_EXTENSION())
.pipe(gulp.dest(COMPILED_DIRECTORY + "/components"));
License
Copyright (c) 2016 Dlmma IVS. Released under the MIT license.