1.7.0 • Published 9 years ago

goog-class-to-es6 v1.7.0

Weekly downloads
1
License
MIT
Repository
github
Last release
9 years ago

googclass-to-es6class

Transform a google closure class defined using goog.defineClass into an es6 class

For example:

const Parent = goog.require('some.ns.Parent');

const FooBar = goog.defineClass(Parent, {
  /**
   * Creates a new instance of...
   * @param {Object} name
   */
  constructor: function(name) {
    this.name = name;
  }
});

exports = FooBar;

Will be transformed into:

const Parent = goog.require('some.ns.Parent');

class FooBar extends Parent {
  /**
   * Creates a new instance of...
   * @param {Object} name
   */
  constructor(name) {
    super(name);

    this.name = name;
  }
}

exports = FooBar;

How to use it

Install from npm

npm i goog-class-to-es6 -g

Transform a file

Provide the name of the file. The transformed class will be written to stdout:

goog-class-to-es6 some_goog_define_class.js

Do inline replacement. The file will be overwritten.

goog-class-to-es6 -i some_goog_define_class.js

Write to another file

goog-class-to-es6 some_goog_define_class.js output_file_es6.js

Testing

# 1. Clone this repo
# 2. Install
npm i
# 3. Test
npm test

Changelog

  • 1.4.0 Add empty line at the end of file if original file has it.
  • 1.5.0 Skip files without goog.defineClass.
  • 1.6.0 Add support for functions declared like: foo() {
  • 1.7.0 Escape closure type casts because Babel strips them.
1.7.0

9 years ago

1.6.0

9 years ago

1.5.0

9 years ago

1.4.0

9 years ago

1.3.2

9 years ago

1.3.1

10 years ago

1.3.0

10 years ago

1.2.0

10 years ago

1.1.0

10 years ago

1.0.3

10 years ago

1.0.2

10 years ago

1.0.1

10 years ago

1.0.0

10 years ago