ES6 Command Line Class Generator
$ npm install -g es6class
es6class
allows you to generate EcmaScript 6 class files really fast with the command line.
$ es6class file.js MyClass
This will generate a JavaScript ES6 file called file.js
with the following code.
class MyClass {
constructor(options) {
}
}
To implement class inheritance, use -e
option
$ es6class file.js MyClass -e ParentClass
Will generate
class MyClass extends ParentClass { ... }
You can specify methods to implement with -m
, each method separated by a space.
$ es6class fileName.js ClassName -m doSomething doSomethingElse
Will output the following:
class ClassName {
constructor(options) {
}
doSomething() {
}
doSomethingElse() {
}
}
ES6 Allows you to create accessors properties get
and set
and also static
methods. Create them by prefixing your method name with get.
set.
or .static
$ es6class fileName.js ClassName -m static.doSomething get.name set.name
Output
class ClassName {
constructor(options) {
}
static doSomething() {
}
get name() {
}
set name() {
}
}
$ npm test
NOTE: This is my first NPM published module and CLI Tool. Feedback and Issues will be really appreciated ! Thanks.