You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I want override the default toString in both lua and js.
So normally I could do that in JavaScript with the Object.setPrototypeOf function, which finally call Object.defineProperty after babel-transformation, to change the proto chain .
However, I found that castl defines the Object.defineProperty with rawset, and also does not expose the setmetatable function.
So I'd like to ask how can I make use of the custom toString and __tostring in both lua and javascript
The text was updated successfully, but these errors were encountered:
constutil=require("util")// also as a custom runtime-lib for luaconstversion={major: 1,minor: 2,patch: 2}Object.setPrototypeOf(version,{toString(){returnutil.format("%d.%d.%d%s",this.major,this.minor,this.patch,this.pre_release ? this.pre_release : "")}})module.exports={_NAME: "sample-project",_VERSION: ""+version,_VERSION_TABLE: version}
I want override the default
toString
in both lua and js.So normally I could do that in JavaScript with the
Object.setPrototypeOf
function, which finally callObject.defineProperty
afterbabel-transformation
, to change the proto chain .However, I found that
castl
defines theObject.defineProperty
withrawset
, and also does not expose thesetmetatable
function.So I'd like to ask how can I make use of the custom
toString
and__tostring
in bothlua
andjavascript
The text was updated successfully, but these errors were encountered: