(fn split [string] (accumulate [res [] v _ (string:gmatch "%S+")] (do (table.insert res v) res))) (fn ends-with [string end] (= (string.sub string (- (# end))) end)) (fn trim [str] (str:match "^%s*(.-)%s*$")) (fn truncate [str len ellipsis] (if (and (= (type str) "string") (< 0 (# str))) (if (< (# str) len) str (.. (trim (luna.utf.sub str 1 len)) (or ellipsis "..."))) "")) {: split : ends-with : truncate}