about summary refs log tree commit diff stats
path: root/src/js/javascript.nim
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2022-11-29 22:32:38 +0100
committerbptato <nincsnevem662@gmail.com>2022-11-29 22:32:52 +0100
commit6c4b7671df166bec49b1a175f759974ff5962a38 (patch)
tree3c31ced89b880df1c3870145667503bea24ee5e3 /src/js/javascript.nim
parentf2daba3542cabb4741e2dc38d1bf36a2d1564f60 (diff)
downloadchawan-6c4b7671df166bec49b1a175f759974ff5962a38.tar.gz
Add siteconf, fix lineedit bugs
This enables rule-based dynamic url rewriting.
Also, lineedit is a bit less broken now (though it's still less than
ideal.)
Diffstat (limited to 'src/js/javascript.nim')
-rw-r--r--src/js/javascript.nim3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/js/javascript.nim b/src/js/javascript.nim
index cd4ea6da..99a083d3 100644
--- a/src/js/javascript.nim
+++ b/src/js/javascript.nim
@@ -673,6 +673,9 @@ proc fromJS[T](ctx: JSContext, val: JSValue): Option[T] =
       return none(T)
     return some(op)
 
+proc getJSFunction*[T, U](ctx: JSContext, val: JSValue): Option[(proc(x: T): Option[U])] =
+  return fromJS[(proc(x: T): Option[U])](ctx, val)
+
 func toJSString(ctx: JSContext, str: string): JSValue =
   return JS_NewString(ctx, cstring(str))