UNPKG

litejs

Version:

Single-page application framework

42 lines (34 loc) 814 B
!function(exports) { exports.encode = function(o) { return encode(o, "") } var hasOwn = Object.prototype.hasOwnProperty function encode(o, pre, opts) { var i , s = [] , c = typeof o if (c === "string") { i = o.split("'") c = o.split('"') if (i > 1 || c > 1) { return pre + ( i > c ? '"' + s.join("").replace(/"/, '\\"') + '"' : "'" + s.join("").replace(/'/, "''") + "'" ) } return pre + o } if (o && c === "object") { if(Array.isArray(o)) { for (i = o.length; i--; s[i] = encode(o[i], " ").slice(2)); return pre + "- " + s.join("\n" + pre + "- ") } for (i in o) hasOwn.call(o,i) && s.push(i + ": " + encode(o[i], "")) return pre + s.join("\n" + pre) } return o==null?'null':pre + o } function decode(str, opts) { } }(this)