Skip to content

Instantly share code, notes, and snippets.

View cheesits456's full-sized avatar
❤️
Black Lives Matter

Quin cheesits456

❤️
Black Lives Matter
View GitHub Profile
@cheesits456
cheesits456 / uneval.js
Last active January 12, 2020 12:36 — forked from cho45/uneval.js
Stringify multiple JS Object Types
function uneval(o) {
switch (typeof o) {
case "undefined": return "(void 0)";
case "boolean": return String(o);
case "number": return String(o);
case "string": return `"${o.replace(/\W/gi, function(_) { return `\\u${(0x10000 + _.charCodeAt(0)).toString(16).slice(1)}` })}"`;
case "function": return `(${o.toString()})`;
case "object":
if (o == null) return "null";
let ret, type = Object.prototype.toString.call(o).match(/\[object (.+)\]/);