diff options
Diffstat (limited to 'src/js/tojs.nim')
-rw-r--r-- | src/js/tojs.nim | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/js/tojs.nim b/src/js/tojs.nim index e614c451..bf2bfe61 100644 --- a/src/js/tojs.nim +++ b/src/js/tojs.nim @@ -8,6 +8,7 @@ import js/arraybuffer import js/dict import js/error import js/opaque +import js/strings import js/typeptr import types/opt @@ -35,6 +36,9 @@ proc toJS*(ctx: JSContext, promise: EmptyPromise): JSValue proc toJS*(ctx: JSContext, obj: ref object): JSValue proc toJS*(ctx: JSContext, err: JSError): JSValue proc toJS*(ctx: JSContext, f: JSCFunction): JSValue +proc toJS*(ctx: JSContext, abuf: JSArrayBuffer): JSValue +proc toJS*(ctx: JSContext, u8a: JSUint8Array): JSValue +proc toJS*(ctx: JSContext, ns: NarrowString): JSValue # Convert Nim types to the corresponding JavaScript type, with knowledge of # the parent object. @@ -270,6 +274,9 @@ proc toJS*(ctx: JSContext, u8a: JSUint8Array): JSValue = JS_FreeValue(ctx, jsabuf) return ret +proc toJS*(ctx: JSContext, ns: NarrowString): JSValue = + return JS_NewNarrowStringLen(ctx, cstring(ns), csize_t(string(ns).len)) + proc toJSP(ctx: JSContext, parent: ref object, child: var object): JSValue = let p = addr child # Save parent as the original ancestor for this tree. |