babel-plugin-es5-function-to-class

1.1.2 • Public • Published
                   @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
                   @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
                   @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@&@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
                   @@@@@@@@@@@@@@@@@@@@@@@@@@@@@/      #@@@@@@@.  %&@@@@@# .@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
                   @@@@@@@@@@@@@@@@@@@ (@@@@@@@@&       @@@@@@&  %%&@@@&/   @@@@@@@@@@@@@@@@@@@@@@@@@@@@@
                   @@@@@@@@@@@@@@@@@@@@  @@@@@@@        @@@@@@ /%%%%%%%   #%#@@@@@@@@@@@@@@@@@@@@@@@@@@@@
                   @@@@@@@@@@@@@@@@@@@@   @@@@.         @@@@@@%%%%%%%   #%%#%#@@@@@@@@@@@@@@@@@@@@@@@@@@@
                   @@@@@@@@@@@@@@@@@@@@@, @@@@         (@@@@#%%%%%%*  (%%%%%%, &@@@@@@@@@@@@@@@@@@@@@@@@@
                   @@@@@@@@@@@@@@@@@@@@@@@ @@@          @@@*%%%%%%  (%%%%%%.  #%@@@@@@@@@@@@@@@@@@@@@@@@@
                   @@@@@@@@@@@@@@@@@@@@@@@@@@@* @@         %%%%%  /%%%%%%   #%%#@@@@@@@@@@@@@@@@@@@@@@@@@
                   @@@@@@@@@@@@@@@@@@ *@@@@@@@@@@@&       #%%%   %%%%%#  .%%%*  &@@@@@@@@@@@@@@@@@@@@@@@@
                   @@@@@@@@@@@@@@@@@@  ,@@@@@@@@@@@       %%%  %%%%%   %%%.     /@@@@@@@@@@@@@@@@@@@@@@@@
                   @@@@@@@@@@@@@@@@@@(    @@@@@@@&       &&%  %%%%  %%%        *@@@@@@@@@@@@@@@@@@@@@@@@@
                   @@@@@@@@@@@@@@@@@@@         @@       %&% /%%(  %%          @%@@@@@@@@@@@@@@@@@@@@@@@@@
                   @@@@@@@@@@@@@@@@@@@@                 && &&% %%.          .@,/@@@@@@@@@@@@@@@@@@@@@@@@@
                   @@@@@@@@@@@@@@@@@@@@@@/             (& && #%           ,@@% @@@@@@@@@@@@@@@@@@@@@@@@@@
                   @@@@@@@@@@@@@@@@@@@@@@@@/  #(       & &.         ,@@@@@@@* &@@@@@@@@@@@@@@@@@@@@@@@@@@
                   @@@@@@@@@@@@@@@@@@@@@@@@@@& @@,    . #      ,@@@@&@@@@@@(  @@@@@@@@@@@@@@@@@@@@@@@@@@@
                   @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@(  *    @@@@@@%(#/%@@@@  %@@@@@@@@@@@@@@@@@@@@@@@@@@@@
                   @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@      @@@@@@@@@&&@@@& .%%@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
                   @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@    @&      .,*.   %%%% @@@@@@@@@@@@@@@@@@@@@@@@@@@@@
                   @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@.    @        ,&&&&&, %%@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
                   @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@%@@  &    &(   .#&&&%, %@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
                   @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@   * .              (@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
                   @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@  @            . *  @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
                   @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@.@@.        #  &( .@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
                   @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@%   / /&  (*/& @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
                   @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@/, /* *,    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
                   @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ #,    @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
                   @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@. @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
                   @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
                   @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

babel-plugin-es5-function-to-class

Live Demo For Babel-Plugin 💻

IO

Input

function Controller(param1, param2) {
    const name = "hello";
    let age = 21;
  }
 
  Controller.prototype.name = "hello";
 
  Controller.prototype.contributeTo = function(param) {
    var foo = "world-k";
  };
 
  Controller.staticMethod = function(param) {
    var bar = "world-cli";
  };
 
  Object.defineProperty(Controller.prototype, "hello", {
    get: function() {
      return "world";
    },
    set: function(name) {
      console.log("Do anything with " + name);
    }
  });
 
  Object.defineProperty(Controller.prototype, "lastname", {
    get: function() {
      return "kiwi";
    }
  });

output

class Controller {
  constructor(param1, param2) {
    const name = "hello";
    let age = 21;
    this.name = "hello"
  }
 
  contributeTo(param) {
    var foo = "world-k";
  }
 
  static staticMethod(param) {
    var bar = "world-cli";
  }
 
  get hello() {
    return "world";
  }
 
  set hello(name) {
    console.log("Do anything with " + name);
  }
 
  get lastname() {
    return "kiwi";
  }
 
}

Features 💯

  • Methods on prototype
  • Static Methods on prototype
  • Variables and Literals on prototype
  • Getters, Setters with defineProperty
  • Block-level Variables

Note : The babel-plugin-es5-function-to-class will only work properly if there is only one function declared in the input file else it will overwrite with the newest declared function. Will resolve this soon 😄

Readme

Keywords

Package Sidebar

Install

npm i babel-plugin-es5-function-to-class

Weekly Downloads

2

Version

1.1.2

License

ISC

Unpacked Size

22.4 kB

Total Files

5

Last publish

Collaborators

  • anixsaha