about summary refs log tree commit diff stats
path: root/src/loader/headers.nim
diff options
context:
space:
mode:
Diffstat (limited to 'src/loader/headers.nim')
-rw-r--r--src/loader/headers.nim13
1 files changed, 5 insertions, 8 deletions
diff --git a/src/loader/headers.nim b/src/loader/headers.nim
index f097fa4f..20764760 100644
--- a/src/loader/headers.nim
+++ b/src/loader/headers.nim
@@ -22,18 +22,15 @@ type
 
 jsDestructor(Headers)
 
-proc fromJS2*(ctx: JSContext, val: JSValue, res: var JSResult[HeadersInit]) =
+proc fromJSHeadersInit(ctx: JSContext; val: JSValue): JSResult[HeadersInit] =
   if JS_IsUndefined(val) or JS_IsNull(val):
-    res.err(nil)
-    return
+    return err(nil)
   if isSequence(ctx, val):
     let x = fromJS[seq[(string, string)]](ctx, val)
     if x.isSome:
-      res.ok(HeadersInit(t: HEADERS_INIT_SEQUENCE, s: x.get))
-  else:
-    let x = fromJS[Table[string, string]](ctx, val)
-    if x.isSome:
-      res.ok(HeadersInit(t: HEADERS_INIT_TABLE, tab: x.get))
+      return ok(HeadersInit(t: HEADERS_INIT_SEQUENCE, s: x.get))
+  let x = ?fromJS[Table[string, string]](ctx, val)
+  return ok(HeadersInit(t: HEADERS_INIT_TABLE, tab: x))
 
 proc fill*(headers: Headers, s: seq[(string, string)]) =
   for (k, v) in s: