I am working on a js tool which will generate Js class file (myclass.js) from an object, for example:
myObj = { width: 0,
height: 0,
getWidth: [Function],
getHeight: [Function] }
I want to generate a js file myClass.js that contains the class:
class MyClass {
constructor (width, height) {
this.width = width;
this.height = height;
}
getWidth () { return this.width ; }
getHeight () { return this.height; }
}
I think about myObj.construct.toString() that return all code of class, but it works just when "myObj" is an instance of the class, in my case "MyObj" will generated dynamically.
Aucun commentaire:
Enregistrer un commentaire