Skip to content

Instantly share code, notes, and snippets.

@jasp402
Created October 30, 2019 19:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jasp402/ff1997bc269ac392404fb3fa613c10ea to your computer and use it in GitHub Desktop.
Save jasp402/ff1997bc269ac392404fb3fa613c10ea to your computer and use it in GitHub Desktop.
Generate Class with Babel
"use strict";
function _instanceof(left, right) {
if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
return !!right[Symbol.hasInstance](left);
} else {
return left instanceof right;
}
}
function _classCallCheck(instance, Constructor) {
if (!_instanceof(instance, Constructor)) {
throw new TypeError("Cannot call a class as a function");
}
}
function _defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ("value" in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
}
}
function _createClass(Constructor, protoProps, staticProps) {
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
if (staticProps) _defineProperties(Constructor, staticProps);
return Constructor;
}
let source = [
{
key: "constrcutor",
value: function constrcutor() {
this.test = function () {
};
this.that = function () {
};
this['method'] = this['method'].bind(this);
this['casita'] = this['casita'].bind(this);
}
},
{
key: "method",
value: function method() {
return 'string';
}
},
{
key: "casita",
value: function method() {
return 'casa';
}
}
];
var test = function () {
function test() {
_classCallCheck(this, test);
}
_createClass(test, source);
return test;
}();
let a = new test();
console.log(a.casita());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment