diff options
Diffstat (limited to 'src/js/tojs.nim')
-rw-r--r-- | src/js/tojs.nim | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/js/tojs.nim b/src/js/tojs.nim index 2936ba28..c79d1bf2 100644 --- a/src/js/tojs.nim +++ b/src/js/tojs.nim @@ -105,6 +105,15 @@ makeToJSP(Result) makeToJSP(JSValue) makeToJSP(JSDict) +proc defineProperty(ctx: JSContext, this: JSValue, name: JSAtom, + prop: JSValue, flags = cint(0)) = + if JS_DefinePropertyValue(ctx, this, name, prop, flags) <= 0: + raise newException(Defect, "Failed to define property string") + +proc definePropertyC*(ctx: JSContext, this: JSValue, name: JSAtom, + prop: JSValue) = + ctx.defineProperty(this, name, prop, JS_PROP_CONFIGURABLE) + proc defineProperty(ctx: JSContext, this: JSValue, name: string, prop: JSValue, flags = cint(0)) = if JS_DefinePropertyValueStr(ctx, this, cstring(name), prop, flags) <= 0: |