aboutsummaryrefslogtreecommitdiff
path: root/lux-js
diff options
context:
space:
mode:
Diffstat (limited to 'lux-js')
-rw-r--r--lux-js/source/program.lux13
1 files changed, 11 insertions, 2 deletions
diff --git a/lux-js/source/program.lux b/lux-js/source/program.lux
index 14e3b812e..3232e6c82 100644
--- a/lux-js/source/program.lux
+++ b/lux-js/source/program.lux
@@ -8,6 +8,7 @@
["." try (#+ Try)]
["." exception (#+ exception:)]
["." io (#+ IO io)]
+ ["." function]
[parser
[cli (#+ program:)]]
[concurrency
@@ -481,8 +482,16 @@
)
@.js
- (as-is (import: (eval [Text] #? Any))
-
+ (as-is (def: (eval code)
+ (-> Text (Maybe Any))
+ ## Note: I have to call "eval" this way
+ ## in order to avoid a quirk of calling eval in Node
+ ## when the code is running under "use strict";.
+ (let [return ("js apply" (function.identity ("js constant" "eval")) code)]
+ (if ("js object null?" return)
+ #.None
+ (#.Some return))))
+
(def: (evaluate! alias input)
(-> Text _.Expression (Try Any))
(do try.monad