aboutsummaryrefslogtreecommitdiff
path: root/utils.moon
diff options
context:
space:
mode:
Diffstat (limited to 'utils.moon')
-rw-r--r--utils.moon8
1 files changed, 7 insertions, 1 deletions
diff --git a/utils.moon b/utils.moon
index f267c7d..471b28e 100644
--- a/utils.moon
+++ b/utils.moon
@@ -7,6 +7,10 @@ utils = {
i += 1
return true
+ size: (t)->
+ with n = 0
+ for _ in pairs(t) do n += 1
+
repr: (x)->
switch type(x)
when 'table'
@@ -18,7 +22,9 @@ utils = {
else
"{#{table.concat(["[#{utils.repr(k)}]= #{utils.repr(v)}" for k,v in pairs x], ", ")}}"
when 'string'
- if not x\find[["]] and not x\find"\n" and not x\find"\\"
+ if x == "\n"
+ return "'\\n'"
+ elseif not x\find[["]] and not x\find"\n" and not x\find"\\"
"\""..x.."\""
elseif not x\find[[']] and not x\find"\n" and not x\find"\\"
"\'"..x.."\'"