aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/lux/target/js.lux
diff options
context:
space:
mode:
Diffstat (limited to 'stdlib/source/lux/target/js.lux')
-rw-r--r--stdlib/source/lux/target/js.lux33
1 files changed, 20 insertions, 13 deletions
diff --git a/stdlib/source/lux/target/js.lux b/stdlib/source/lux/target/js.lux
index b66f40e05..429579655 100644
--- a/stdlib/source/lux/target/js.lux
+++ b/stdlib/source/lux/target/js.lux
@@ -79,18 +79,19 @@
(def: sanitize
(-> Text Text)
- (`` (|>> (~~ (template [<find> <replace>]
+ (`` (|>> (~~ (template [<replace> <find>]
[(text.replace-all <find> <replace>)]
- ["\" "\\"]
- [text.tab "\t"]
- [text.vertical-tab "\v"]
- [text.null "\0"]
- [text.back-space "\b"]
- [text.form-feed "\f"]
- [text.new-line "\n"]
- [text.carriage-return "\r"]
- [text.double-quote (format "\" text.double-quote)]
+ ["\\" "\"]
+ ["\t" text.tab]
+ ["\v" text.vertical-tab]
+ ["\0" text.null]
+ ["\b" text.back-space]
+ ["\f" text.form-feed]
+ ["\n" text.new-line]
+ ["\r" text.carriage-return]
+ [(format "\" text.double-quote)
+ text.double-quote]
))
)))
@@ -170,8 +171,8 @@
(text.enclose ["{"
close]))))
- (def: #export (function name inputs body)
- (-> Var (List Var) Statement Computation)
+ (def: #export (function! name inputs body)
+ (-> Var (List Var) Statement Statement)
(|> body
..block
(format "function " (:representation name)
@@ -180,6 +181,12 @@
(text.join-with ..argument-separator)
..argument)
" ")
+ :abstraction))
+
+ (def: #export (function name inputs body)
+ (-> Var (List Var) Statement Computation)
+ (|> (..function! name inputs body)
+ :representation
..argument
:abstraction))
@@ -392,7 +399,7 @@
(def: #export (switch input cases default)
(-> Expression (List [(List Literal) Statement]) (Maybe Statement) Statement)
- (:abstraction (format "switch (" (:representation input) ")" text.new-line
+ (:abstraction (format "switch (" (:representation input) ") "
(|> (format (|> cases
(list@map (.function (_ [when then])
(format (|> when