Created
October 30, 2019 19:22
-
-
Save jasp402/ff1997bc269ac392404fb3fa613c10ea to your computer and use it in GitHub Desktop.
Generate Class with Babel
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"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