about summary refs log tree commit diff stats
path: root/src/js/tojs.nim
diff options
context:
space:
mode:
Diffstat (limited to 'src/js/tojs.nim')
-rw-r--r--src/js/tojs.nim7
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.
2'>132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241