@dmail/uneval
Advanced tools
Comparing version 4.4.0 to 4.5.0
@@ -1,2 +0,330 @@ | ||
var __dmail_uneval__=function(n){"use strict";function t(n){return(t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(n){return typeof n}:function(n){return n&&"function"==typeof Symbol&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n})(n)}function e(n,t,e){return t in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}function o(n){for(var t=1;t<arguments.length;t++){var o=null!=arguments[t]?arguments[t]:{},r=Object.keys(o);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(o).filter(function(n){return Object.getOwnPropertyDescriptor(o,n).enumerable}))),r.forEach(function(t){e(n,t,o[t])})}return n}function r(n,t){if(null==n)return{};var e,o,r=function(n,t){if(null==n)return{};var e,o,r={},c=Object.keys(n);for(o=0;o<c.length;o++)e=c[o],t.indexOf(e)>=0||(r[e]=n[e]);return r}(n,t);if(Object.getOwnPropertySymbols){var c=Object.getOwnPropertySymbols(n);for(o=0;o<c.length;o++)e=c[o],t.indexOf(e)>=0||Object.prototype.propertyIsEnumerable.call(n,e)&&(r[e]=n[e])}return r}var c=function(n,t){var e=t.parenthesis,o=t.useNew,r=n;return e&&(r="(".concat(n,")")),o&&(r="new ".concat(r)),r},i=function(n){var t=n.count,e=n.useTabs,o=n.size;return e?"\n"+"\t".repeat(t):"\n"+" ".repeat(t*o)},u=function(n,t){var e=t.depth,o=void 0===e?0:e,r=t.indentUsingTab,c=t.indentSize;return"".concat(i({count:o+1,useTabs:r,size:c})).concat(n)},a=function(n,t){return"".concat(u(n,t)).concat((o=(e=t).depth,r=void 0===o?0:o,c=e.indentUsingTab,a=e.indentSize,i({count:r,useTabs:c,size:a})));var e,o,r,c,a},f=function(n){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},e=t.seen,r=void 0===e?[]:e;if(r.indexOf(n)>-1)return"Symbol.for('circular')";r.push(n);for(var i,f="",d=Object.getOwnPropertyNames(n),l=0,s=d.length,v=t.depth,b=void 0===v?0:v,h=t.compact,g=o({},t,{depth:b+1,seen:r});l<s;){var y=d[l],O=parseInt(y,10),m=p(Number.isInteger(O)?O:y,g),S=p(n[y],g);f+=h?0===l?"".concat(m,": ").concat(S):", ".concat(m,": ").concat(S):0===l?"".concat(m,": ").concat(S):",".concat(u("".concat(m,": ").concat(S),t)),l++}return i=f.length?"".concat(h?f:a(f,t)):"",i=t.objectConstructor?"Object({".concat(i,"})"):"{".concat(i,"}"),c(i,t)},d=Object.prototype.toString,l={Array:function(n){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},e=t.seen,r=void 0===e?[]:e;if(r.indexOf(n)>-1)return"Symbol.for('circular')";r.push(n);for(var i,f="",d=0,l=n.length,s=t.compact,v=t.depth,b=o({},t,{depth:(void 0===v?0:v)+1,seen:r});d<l;){var h=n.hasOwnProperty(d)?p(n[d],b):"";f+=s?0===d?h:h?", ".concat(h):",":0===d?h:",".concat(u(h,t)),d++}return i=f.length?s?"".concat(f):a(f,t):"",i="[".concat(i,"]"),c(i,t)},Boolean:function(n){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},e=t.depth,r=void 0===e?0:e,i=p(n.valueOf(),o({},t,{depth:r+1}));return c("Boolean(".concat(i,")"),t)},Date:function(n){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},e=t.depth,r=void 0===e?0:e,i=p(n.valueOf(),o({},t,{depth:r+1}));return c("Date(".concat(i,")"),t)},Error:function(n){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},e=t.depth,r=void 0===e?0:e,i=p(n.message,o({},t,{depth:r+1}));return c("".concat(n.name,"(").concat(i,")"),t)},Number:function(n){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},e=t.depth,r=void 0===e?0:e,i=p(n.valueOf(),o({},t,{depth:r+1}));return c("Number(".concat(i,")"),t)},Object:f,RegExp:function(n){return n.toString()},String:function(n,t){var e=t.depth,r=void 0===e?0:e,i=p(n.valueOf(),o({},t,{depth:r+1}));return c("String(".concat(i,")"),t)}},s=function(n,t){var e=t.singleQuote,o=function(n){for(var t=String(n),e=0,o=t.length,r="";e<o;){var c=t[e];r+='"'===c||"'"===c||"\\"===c?"\\".concat(c):"\n"===c?"\\n":"\r"===c?"\\r":"\u2028"===c?"\\u2028":"\u2029"===c?"\\u2029":c,e++}return r}(n);return e?"'".concat(o,"'"):'"'.concat(o,'"')},v={boolean:function(n){return n.toString()},function:function(n,t){var e,o=t.showFunctionBody,r=t.parenthesis,c=t.depth;if(o)e=n.toString();else{var i=void 0===n.prototype?"() =>":"function ".concat(0===c?n.name:"","()");e="".concat(i," {/* hidden */}")}return r?"(".concat(e,")"):e},null:function(){return"null"},number:function(n){return Object.is(n,-0)?"-0":n.toString()},object:function(n,e){var r=function(n){if("object"===t(n)&&null===Object.getPrototypeOf(n))return"Object";var e=d.call(n).slice("[object ".length,-1);if("Object"===e){var o=n.constructor.name;if("Object"!==o)return o}return e}(n);return r in l?l[r](n,e):c("".concat(r,"(").concat(f(n,e),")"),o({},e,{parenthesis:!1}))},string:s,symbol:function(n,t){var e=n.toString(),o=e.indexOf("("),r=e.indexOf(")"),c=e.slice(o+1,r),i=c?s(c,t):"",u="Symbol(".concat(i,")");return t.parenthesis?"".concat(u):u},undefined:function(){return"undefined"}},p=function(n){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},c=e.parenthesis,i=void 0!==c&&c,u=e.singleQuote,a=void 0!==u&&u,f=e.useNew,d=void 0!==f&&f,l=e.objectConstructor,s=void 0!==l&&l,p=e.compact,b=void 0!==p&&p,h=e.showFunctionBody,g=void 0!==h&&h,y=e.indentUsingTab,O=void 0!==y&&y,m=e.indentSize,S=void 0===m?2:m,j=e.depth,w=void 0===j?0:j,P=r(e,["parenthesis","singleQuote","useNew","objectConstructor","compact","showFunctionBody","indentUsingTab","indentSize","depth"]),z=function(n){return null===n?"null":void 0===n?"undefined":t(n)}(n);return v[z](n,o({parenthesis:i,singleQuote:a,useNew:d,objectConstructor:s,compact:b,showFunctionBody:g,indentUsingTab:O,indentSize:S,depth:w},P))};return n.uneval=p,n}({}); | ||
//# sourceMappingURL=main.js.map | ||
System.register([], function (n, e) { | ||
"use strict"; | ||
return { | ||
execute: function () { | ||
function e(n) { | ||
return (e = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (n) { | ||
return typeof n; | ||
} : function (n) { | ||
return n && "function" == typeof Symbol && n.constructor === Symbol && n !== Symbol.prototype ? "symbol" : typeof n; | ||
})(n); | ||
} | ||
function t(n, e, t) { | ||
return e in n ? Object.defineProperty(n, e, { | ||
value: t, | ||
enumerable: !0, | ||
configurable: !0, | ||
writable: !0 | ||
}) : n[e] = t, n; | ||
} | ||
function r(n) { | ||
for (var e = 1; e < arguments.length; e++) { | ||
var r = null != arguments[e] ? arguments[e] : {}, | ||
o = Object.keys(r); | ||
"function" == typeof Object.getOwnPropertySymbols && (o = o.concat(Object.getOwnPropertySymbols(r).filter(function (n) { | ||
return Object.getOwnPropertyDescriptor(r, n).enumerable; | ||
}))), o.forEach(function (e) { | ||
t(n, e, r[e]); | ||
}); | ||
} | ||
return n; | ||
} | ||
var o = Object.prototype.toString, | ||
i = function (n) { | ||
if ("object" === e(n) && null === Object.getPrototypeOf(n)) return "Object"; | ||
var t = o.call(n).slice("[object ".length, -1); | ||
if ("Object" === t) { | ||
var r = n.constructor.name; | ||
if ("Object" !== r) return r; | ||
} | ||
return t; | ||
}, | ||
c = function (n) { | ||
return null === n ? "null" : void 0 === n ? "undefined" : e(n); | ||
}, | ||
a = function (n, e) { | ||
var t = e.depth, | ||
r = e.indentUsingTab, | ||
o = e.indentSize; | ||
return "".concat(u({ | ||
count: t + 1, | ||
useTabs: r, | ||
size: o | ||
})).concat(n); | ||
}, | ||
u = function (n) { | ||
var e = n.count, | ||
t = n.useTabs, | ||
r = n.size; | ||
return t ? "\n" + "\t".repeat(e) : "\n" + " ".repeat(e * r); | ||
}, | ||
s = function (n, e) { | ||
var t = e.depth, | ||
r = e.indentUsingTab, | ||
o = e.indentSize; | ||
return "".concat(a(n, { | ||
depth: t, | ||
indentUsingTab: r, | ||
indentSize: o | ||
})).concat(function (n) { | ||
var e = n.depth, | ||
t = n.indentUsingTab, | ||
r = n.indentSize; | ||
return u({ | ||
count: e, | ||
useTabs: t, | ||
size: r | ||
}); | ||
}({ | ||
depth: t, | ||
indentUsingTab: r, | ||
indentSize: o | ||
})); | ||
}, | ||
d = { | ||
boolean: function (n) { | ||
return n.toString(); | ||
}, | ||
null: function () { | ||
return "null"; | ||
}, | ||
number: function (n) { | ||
return Object.is(n, -0) ? "-0" : n.toString(); | ||
}, | ||
string: function (n, e) { | ||
var t = e.singleQuote, | ||
r = function (n) { | ||
for (var e = String(n), t = 0, r = e.length, o = ""; t < r;) { | ||
var i = e[t]; | ||
o += '"' === i || "'" === i || "\\" === i ? "\\".concat(i) : "\n" === i ? "\\n" : "\r" === i ? "\\r" : "\u2028" === i ? "\\u2028" : "\u2029" === i ? "\\u2029" : i, t++; | ||
} | ||
return o; | ||
}(n); | ||
return t ? "'".concat(r, "'") : '"'.concat(r, '"'); | ||
}, | ||
symbol: function (n, e) { | ||
var t = e.nestedUneval, | ||
r = e.parenthesis, | ||
o = n.toString(), | ||
i = o.indexOf("("), | ||
c = o.indexOf(")"), | ||
a = o.slice(i + 1, c), | ||
u = a ? t(a) : "", | ||
s = "Symbol(".concat(u, ")"); | ||
return r ? "".concat(s) : s; | ||
}, | ||
undefined: function () { | ||
return "undefined"; | ||
} | ||
}, | ||
f = function (n, e) { | ||
var t = e.parenthesis, | ||
r = e.useNew, | ||
o = n; | ||
return t && (o = "(".concat(n, ")")), r && (o = "new ".concat(o)), o; | ||
}, | ||
p = function (n, e) { | ||
var t = e.nestedUneval, | ||
r = e.seen, | ||
o = void 0 === r ? [] : r, | ||
i = e.compact, | ||
c = e.depth, | ||
u = e.indentUsingTab, | ||
d = e.indentSize, | ||
p = e.objectConstructor, | ||
l = e.parenthesis, | ||
v = e.useNew; | ||
if (o.indexOf(n) > -1) return "Symbol.for('circular')"; | ||
o.push(n); | ||
for (var b, h = "", g = Object.getOwnPropertyNames(n), y = 0, m = g.length; y < m;) { | ||
var S = g[y], | ||
O = parseInt(S, 10), | ||
w = t(Number.isInteger(O) ? O : S), | ||
U = t(n[S], { | ||
seen: o | ||
}); | ||
h += i ? 0 === y ? "".concat(w, ": ").concat(U) : ", ".concat(w, ": ").concat(U) : 0 === y ? "".concat(w, ": ").concat(U) : ",".concat(a("".concat(w, ": ").concat(U), { | ||
depth: c, | ||
indentUsingTab: u, | ||
indentSize: d | ||
})), y++; | ||
} | ||
return b = h.length ? "".concat(i ? h : s(h, { | ||
depth: c, | ||
indentUsingTab: u, | ||
indentSize: d | ||
})) : "", b = p ? "Object({".concat(b, "})") : "{".concat(b, "}"), f(b, { | ||
parenthesis: l, | ||
useNew: v | ||
}); | ||
}, | ||
l = { | ||
Array: function (n, e) { | ||
var t = e.seen, | ||
r = void 0 === t ? [] : t, | ||
o = e.nestedUneval, | ||
i = e.compact, | ||
c = e.depth, | ||
u = e.indentUsingTab, | ||
d = e.indentSize, | ||
p = e.parenthesis, | ||
l = e.useNew; | ||
if (r.indexOf(n) > -1) return "Symbol.for('circular')"; | ||
r.push(n); | ||
for (var v, b = "", h = 0, g = n.length; h < g;) { | ||
var y = n.hasOwnProperty(h) ? o(n[h], { | ||
seen: r | ||
}) : ""; | ||
b += i ? 0 === h ? y : y ? ", ".concat(y) : "," : 0 === h ? y : ",".concat(a(y, { | ||
depth: c, | ||
indentUsingTab: u, | ||
indentSize: d | ||
})), h++; | ||
} | ||
return v = b.length ? i ? "".concat(b) : s(b, { | ||
depth: c, | ||
indentUsingTab: u, | ||
indentSize: d | ||
}) : "", v = "[".concat(v, "]"), f(v, { | ||
parenthesis: p, | ||
useNew: l | ||
}); | ||
}, | ||
Boolean: function (n, e) { | ||
var t = e.nestedUneval, | ||
r = e.useNew, | ||
o = e.parenthesis, | ||
i = t(n.valueOf()); | ||
return f("Boolean(".concat(i, ")"), { | ||
useNew: r, | ||
parenthesis: o | ||
}); | ||
}, | ||
Error: function (n, e) { | ||
var t = e.nestedUneval, | ||
r = e.useNew, | ||
o = e.parenthesis, | ||
i = t(n.message); | ||
return f("".concat(n.name, "(").concat(i, ")"), { | ||
useNew: r, | ||
parenthesis: o | ||
}); | ||
}, | ||
Date: function (n, e) { | ||
var t = e.nestedUneval, | ||
r = e.useNew, | ||
o = e.parenthesis, | ||
i = t(n.valueOf()); | ||
return f("Date(".concat(i, ")"), { | ||
useNew: r, | ||
parenthesis: o | ||
}); | ||
}, | ||
Function: function (n, e) { | ||
var t, | ||
r = e.showFunctionBody, | ||
o = e.parenthesis, | ||
i = e.depth; | ||
if (r) t = n.toString();else { | ||
var c = void 0 === n.prototype ? "() =>" : "function ".concat(0 === i ? n.name : "", "()"); | ||
t = "".concat(c, " {/* hidden */}"); | ||
} | ||
return o ? "(".concat(t, ")") : t; | ||
}, | ||
Number: function (n, e) { | ||
var t = e.nestedUneval, | ||
r = e.useNew, | ||
o = e.parenthesis, | ||
i = t(n.valueOf()); | ||
return f("Number(".concat(i, ")"), { | ||
useNew: r, | ||
parenthesis: o | ||
}); | ||
}, | ||
Object: p, | ||
RegExp: function (n) { | ||
return n.toString(); | ||
}, | ||
String: function (n, e) { | ||
var t = e.nestedUneval, | ||
r = e.useNew, | ||
o = e.parenthesis, | ||
i = t(n.valueOf()); | ||
return f("String(".concat(i, ")"), { | ||
useNew: r, | ||
parenthesis: o | ||
}); | ||
} | ||
}; | ||
n("uneval", function (n) { | ||
var e = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : {}, | ||
t = e.parenthesis, | ||
o = void 0 !== t && t, | ||
a = e.singleQuote, | ||
u = void 0 !== a && a, | ||
s = e.useNew, | ||
v = void 0 !== s && s, | ||
b = e.objectConstructor, | ||
h = void 0 !== b && b, | ||
g = e.compact, | ||
y = void 0 !== g && g, | ||
m = e.showFunctionBody, | ||
S = void 0 !== m && m, | ||
O = e.indentUsingTab, | ||
w = void 0 !== O && O, | ||
U = e.indentSize; | ||
return function n(e, t) { | ||
var o = function (n) { | ||
var e = c(n); | ||
return "function" === e ? { | ||
compositeType: "Function" | ||
} : "object" === e ? { | ||
compositeType: i(n) | ||
} : { | ||
primitiveType: e | ||
}; | ||
}(e), | ||
a = o.primitiveType, | ||
u = o.compositeType, | ||
s = r({}, t, { | ||
nestedUneval: function (e) { | ||
var o = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : {}; | ||
return n(e, r({}, t, { | ||
depth: t.depth + 1 | ||
}, o)); | ||
} | ||
}); | ||
return a ? d[a](e, s) : u in l ? l[u](e, s) : f("".concat(u, "(").concat(p(e, s), ")"), r({}, s, { | ||
parenthesis: !1 | ||
})); | ||
}(n, { | ||
parenthesis: o, | ||
singleQuote: u, | ||
useNew: v, | ||
objectConstructor: h, | ||
compact: y, | ||
showFunctionBody: S, | ||
indentUsingTab: w, | ||
indentSize: void 0 === U ? 2 : U, | ||
depth: 0 | ||
}); | ||
}); | ||
} | ||
}; | ||
}); | ||
//# sourceMappingURL=./main.js.map |
@@ -1,2 +0,151 @@ | ||
"use strict";function n(t){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(n){return typeof n}:function(n){return n&&"function"==typeof Symbol&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n})(t)}function t(n,t,e){return t in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}function e(n){for(var e=1;e<arguments.length;e++){var o=null!=arguments[e]?arguments[e]:{},r=Object.keys(o);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(o).filter(function(n){return Object.getOwnPropertyDescriptor(o,n).enumerable}))),r.forEach(function(e){t(n,e,o[e])})}return n}function o(n,t){if(null==n)return{};var e,o,r=function(n,t){if(null==n)return{};var e,o,r={},c=Object.keys(n);for(o=0;o<c.length;o++)e=c[o],t.indexOf(e)>=0||(r[e]=n[e]);return r}(n,t);if(Object.getOwnPropertySymbols){var c=Object.getOwnPropertySymbols(n);for(o=0;o<c.length;o++)e=c[o],t.indexOf(e)>=0||Object.prototype.propertyIsEnumerable.call(n,e)&&(r[e]=n[e])}return r}Object.defineProperty(exports,"__esModule",{value:!0});var r=function(n,t){var e=t.parenthesis,o=t.useNew,r=n;return e&&(r="(".concat(n,")")),o&&(r="new ".concat(r)),r},c=function(n){var t=n.count,e=n.useTabs,o=n.size;return e?"\n"+"\t".repeat(t):"\n"+" ".repeat(t*o)},i=function(n,t){var e=t.depth,o=void 0===e?0:e,r=t.indentUsingTab,i=t.indentSize;return"".concat(c({count:o+1,useTabs:r,size:i})).concat(n)},u=function(n,t){return"".concat(i(n,t)).concat((o=(e=t).depth,r=void 0===o?0:o,u=e.indentUsingTab,a=e.indentSize,c({count:r,useTabs:u,size:a})));var e,o,r,u,a},a=function(n){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=t.seen,c=void 0===o?[]:o;if(c.indexOf(n)>-1)return"Symbol.for('circular')";c.push(n);for(var a,d="",f=Object.getOwnPropertyNames(n),s=0,l=f.length,v=t.depth,b=void 0===v?0:v,h=t.compact,g=e({},t,{depth:b+1,seen:c});s<l;){var y=f[s],O=parseInt(y,10),m=p(Number.isInteger(O)?O:y,g),j=p(n[y],g);d+=h?0===s?"".concat(m,": ").concat(j):", ".concat(m,": ").concat(j):0===s?"".concat(m,": ").concat(j):",".concat(i("".concat(m,": ").concat(j),t)),s++}return a=d.length?"".concat(h?d:u(d,t)):"",a=t.objectConstructor?"Object({".concat(a,"})"):"{".concat(a,"}"),r(a,t)},d=Object.prototype.toString,f={Array:function(n){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=t.seen,c=void 0===o?[]:o;if(c.indexOf(n)>-1)return"Symbol.for('circular')";c.push(n);for(var a,d="",f=0,s=n.length,l=t.compact,v=t.depth,b=e({},t,{depth:(void 0===v?0:v)+1,seen:c});f<s;){var h=n.hasOwnProperty(f)?p(n[f],b):"";d+=l?0===f?h:h?", ".concat(h):",":0===f?h:",".concat(i(h,t)),f++}return a=d.length?l?"".concat(d):u(d,t):"",a="[".concat(a,"]"),r(a,t)},Boolean:function(n){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=t.depth,c=void 0===o?0:o,i=p(n.valueOf(),e({},t,{depth:c+1}));return r("Boolean(".concat(i,")"),t)},Date:function(n){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=t.depth,c=void 0===o?0:o,i=p(n.valueOf(),e({},t,{depth:c+1}));return r("Date(".concat(i,")"),t)},Error:function(n){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=t.depth,c=void 0===o?0:o,i=p(n.message,e({},t,{depth:c+1}));return r("".concat(n.name,"(").concat(i,")"),t)},Number:function(n){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=t.depth,c=void 0===o?0:o,i=p(n.valueOf(),e({},t,{depth:c+1}));return r("Number(".concat(i,")"),t)},Object:a,RegExp:function(n){return n.toString()},String:function(n,t){var o=t.depth,c=void 0===o?0:o,i=p(n.valueOf(),e({},t,{depth:c+1}));return r("String(".concat(i,")"),t)}},s=function(n,t){var e=t.singleQuote,o=function(n){for(var t=String(n),e=0,o=t.length,r="";e<o;){var c=t[e];r+='"'===c||"'"===c||"\\"===c?"\\".concat(c):"\n"===c?"\\n":"\r"===c?"\\r":"\u2028"===c?"\\u2028":"\u2029"===c?"\\u2029":c,e++}return r}(n);return e?"'".concat(o,"'"):'"'.concat(o,'"')},l={boolean:function(n){return n.toString()},function:function(n,t){var e,o=t.showFunctionBody,r=t.parenthesis,c=t.depth;if(o)e=n.toString();else{var i=void 0===n.prototype?"() =>":"function ".concat(0===c?n.name:"","()");e="".concat(i," {/* hidden */}")}return r?"(".concat(e,")"):e},null:function(){return"null"},number:function(n){return Object.is(n,-0)?"-0":n.toString()},object:function(t,o){var c=function(t){if("object"===n(t)&&null===Object.getPrototypeOf(t))return"Object";var e=d.call(t).slice("[object ".length,-1);if("Object"===e){var o=t.constructor.name;if("Object"!==o)return o}return e}(t);return c in f?f[c](t,o):r("".concat(c,"(").concat(a(t,o),")"),e({},o,{parenthesis:!1}))},string:s,symbol:function(n,t){var e=n.toString(),o=e.indexOf("("),r=e.indexOf(")"),c=e.slice(o+1,r),i=c?s(c,t):"",u="Symbol(".concat(i,")");return t.parenthesis?"".concat(u):u},undefined:function(){return"undefined"}},p=function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},c=r.parenthesis,i=void 0!==c&&c,u=r.singleQuote,a=void 0!==u&&u,d=r.useNew,f=void 0!==d&&d,s=r.objectConstructor,p=void 0!==s&&s,v=r.compact,b=void 0!==v&&v,h=r.showFunctionBody,g=void 0!==h&&h,y=r.indentUsingTab,O=void 0!==y&&y,m=r.indentSize,j=void 0===m?2:m,S=r.depth,w=void 0===S?0:S,P=o(r,["parenthesis","singleQuote","useNew","objectConstructor","compact","showFunctionBody","indentUsingTab","indentSize","depth"]),x=function(t){return null===t?"null":void 0===t?"undefined":n(t)}(t);return l[x](t,e({parenthesis:i,singleQuote:a,useNew:f,objectConstructor:p,compact:b,showFunctionBody:g,indentUsingTab:O,indentSize:j,depth:w},P))};exports.uneval=p; | ||
'use strict'; | ||
var entryPointName = "main"; | ||
var groupMap = { | ||
"best": { | ||
"incompatibleNameArray": ["proposal-json-strings", "proposal-optional-catch-binding", "proposal-unicode-property-regex", "syntax-object-rest-spread", "syntax-optional-catch-binding", "transform-dotall-regex"], | ||
"platformCompatMap": { | ||
"node": "8.3" | ||
} | ||
}, | ||
"otherwise": { | ||
"incompatibleNameArray": ["proposal-object-rest-spread", "proposal-optional-catch-binding", "proposal-unicode-property-regex", "proposal-json-strings", "syntax-object-rest-spread", "syntax-optional-catch-binding", "transform-async-to-promises", "transform-arrow-functions", "transform-block-scoped-functions", "transform-block-scoping", "transform-classes", "transform-computed-properties", "transform-destructuring", "transform-dotall-regex", "transform-duplicate-keys", "transform-exponentiation-operator", "transform-for-of", "transform-function-name", "transform-literals", "transform-new-target", "transform-object-super", "transform-parameters", "transform-shorthand-properties", "transform-spread", "transform-sticky-regex", "transform-template-literals", "transform-typeof-symbol", "transform-unicode-regex"], | ||
"platformCompatMap": {} | ||
} | ||
}; | ||
var detect = function detect() { | ||
return { | ||
name: "node", | ||
version: process.version.slice(1) | ||
}; | ||
}; | ||
var valueToVersion = function valueToVersion(value) { | ||
if (typeof value === "number") { | ||
return numberToVersion(value); | ||
} | ||
if (typeof value === "string") { | ||
return stringToVersion(value); | ||
} | ||
throw new TypeError(createValueErrorMessage({ | ||
version: value | ||
})); | ||
}; | ||
var numberToVersion = function numberToVersion(number) { | ||
return { | ||
major: number, | ||
minor: 0, | ||
patch: 0 | ||
}; | ||
}; | ||
var stringToVersion = function stringToVersion(string) { | ||
if (string.indexOf(".") > -1) { | ||
var parts = string.split("."); | ||
return { | ||
major: Number(parts[0]), | ||
minor: parts[1] ? Number(parts[1]) : 0, | ||
patch: parts[2] ? Number(parts[2]) : 0 | ||
}; | ||
} | ||
if (isNaN(string)) { | ||
return { | ||
major: 0, | ||
minor: 0, | ||
patch: 0 | ||
}; | ||
} | ||
return { | ||
major: Number(string), | ||
minor: 0, | ||
patch: 0 | ||
}; | ||
}; | ||
var createValueErrorMessage = function createValueErrorMessage(_ref) { | ||
var value = _ref.value; | ||
return "value must be a number or a string.\nvalue: ".concat(value); | ||
}; | ||
var versionCompare = function versionCompare(versionA, versionB) { | ||
var semanticVersionA = valueToVersion(versionA); | ||
var semanticVersionB = valueToVersion(versionB); | ||
var majorDiff = semanticVersionA.major - semanticVersionB.major; | ||
if (majorDiff > 0) { | ||
return majorDiff; | ||
} | ||
if (majorDiff < 0) { | ||
return majorDiff; | ||
} | ||
var minorDiff = semanticVersionA.minor - semanticVersionB.minor; | ||
if (minorDiff > 0) { | ||
return minorDiff; | ||
} | ||
if (minorDiff < 0) { | ||
return minorDiff; | ||
} | ||
var patchDiff = semanticVersionA.patch - semanticVersionB.patch; | ||
if (patchDiff > 0) { | ||
return patchDiff; | ||
} | ||
if (patchDiff < 0) { | ||
return patchDiff; | ||
} | ||
return 0; | ||
}; | ||
var versionIsBelow = function versionIsBelow(versionSupposedBelow, versionSupposedAbove) { | ||
return versionCompare(versionSupposedBelow, versionSupposedAbove) < 0; | ||
}; | ||
var findHighestVersion = function findHighestVersion() { | ||
for (var _len = arguments.length, values = new Array(_len), _key = 0; _key < _len; _key++) { | ||
values[_key] = arguments[_key]; | ||
} | ||
if (values.length === 0) throw new Error("missing argument"); | ||
return values.reduce(function (highestVersion, value) { | ||
if (versionIsBelow(highestVersion, value)) { | ||
return value; | ||
} | ||
return highestVersion; | ||
}); | ||
}; | ||
var nodeToCompileId = function nodeToCompileId(_ref, groupMap) { | ||
var name = _ref.name, | ||
version = _ref.version; | ||
return Object.keys(groupMap).find(function (compileIdCandidate) { | ||
var platformCompatMap = groupMap[compileIdCandidate].platformCompatMap; | ||
if (name in platformCompatMap === false) { | ||
return false; | ||
} | ||
var versionForGroup = platformCompatMap[name]; | ||
var highestVersion = findHighestVersion(version, versionForGroup); | ||
return highestVersion === version; | ||
}); | ||
}; | ||
// eslint-disable-next-line import/no-unresolved | ||
var compileId = nodeToCompileId(detect(), groupMap); // eslint-disable-next-line import/no-dynamic-require | ||
module.exports = require("./".concat(compileId, "/").concat(entryPointName, ".js")); | ||
//# sourceMappingURL=main.js.map |
{ | ||
"name": "@dmail/uneval", | ||
"version": "4.4.0", | ||
"version": "4.5.0", | ||
"license": "MIT", | ||
@@ -12,20 +12,19 @@ "repository": { | ||
}, | ||
"module": "index.js", | ||
"browser": "dist/browser/main.js", | ||
"main": "dist/node/main.js", | ||
"module": "index.js", | ||
"files": [ | ||
"index.js", | ||
"src", | ||
"dist" | ||
"/index.js", | ||
"/src/", | ||
"/dist/" | ||
], | ||
"engines": { | ||
"node": ">=8.6.0" | ||
}, | ||
"dependencies": {}, | ||
"devDependencies": { | ||
"@jsenv/core": "4.4.0", | ||
"@jsenv/core": "5.6.0", | ||
"@jsenv/eslint-config": "8.0.0", | ||
"@jsenv/eslint-import-resolver": "2.0.0", | ||
"@jsenv/eslint-import-resolver": "4.1.0", | ||
"@jsenv/prettier-config": "1.0.0", | ||
"@jsenv/babel-plugin-description": "1.0.0", | ||
"@dmail/assert": "2.0.0", | ||
"@jsenv/prettier-check-project": "1.0.0", | ||
"@jsenv/babel-config-map": "1.0.0", | ||
"@dmail/assert": "3.0.0", | ||
"babel-eslint": "11.0.0-beta.0", | ||
@@ -40,15 +39,15 @@ "prettier": "1.15.3", | ||
"generate-import-map": "node ./script/generate-import-map/generate-import-map.js", | ||
"lint": "eslint .", | ||
"check-format": "node ./script/check-format/check-format.js", | ||
"start-browsing-server": "node ./script/start-browsing-server/start-browsing-server.js", | ||
"test": "node ./script/test/test.js", | ||
"eslint-check-project": "eslint .", | ||
"prettier-check-project": "node ./script/prettier-check-project/prettier-check-project.js", | ||
"generate-coverage": "node ./script/generate-coverage/generate-coverage.js", | ||
"upload-coverage": "node ./script/upload-coverage/upload-coverage.js", | ||
"start-browsing-server": "node ./script/start-browsing-server/start-browsing-server.js", | ||
"clean": "rimraf dist && rimraf coverage", | ||
"dist": "npm run clean && npm run bundle-browser && npm run bundle-node", | ||
"bundle-browser": "node ./script/bundle-browser/bundle-browser.js", | ||
"bundle-node": "node ./script/bundle-node/bundle-node.js", | ||
"dist": "npm run clean && npm run bundle-browser && npm run bundle-node", | ||
"prepublishOnly": "npm run dist", | ||
"reinstall": "npm run clean && rimraf node_modules && npm install" | ||
"clean": "rimraf dist && rimraf coverage", | ||
"reinstall": "npm run clean && rimraf node_modules && npm install", | ||
"prepublishOnly": "npm run dist" | ||
} | ||
} |
@@ -15,44 +15,2 @@ # uneval | ||
```javascript | ||
import { uneval } from "@dmail/uneval" | ||
console.log( | ||
uneval({ | ||
array: [], | ||
boolean: true, | ||
date: new Date(7), | ||
function: (a) => a, | ||
null: null, | ||
number: 10, | ||
regExp: /ok/, | ||
string: "dmail", | ||
symbol: Symbol("foo"), | ||
typeError: new TypeError("cannot read property 0 of undefined"), | ||
undefined: undefined, | ||
}), | ||
) | ||
``` | ||
Executing above code logs in the console | ||
```javascript | ||
{ | ||
"array": [], | ||
"boolean": true, | ||
"date": Date(7), | ||
"function": () => {/* hidden */}, | ||
"null": null, | ||
"number": 10, | ||
"regExp": /ok/ | ||
"string": "dmail", | ||
"symbol": Symbol("foo"), | ||
"typeError": TypeError("cannot ready property 0 of undefined"), | ||
"undefined": undefined, | ||
} | ||
``` | ||
## Style guide | ||
Prettier and eslint are used to ensure code style and format | ||
## API | ||
@@ -59,0 +17,0 @@ |
import { unevalArray } from "./unevalArray.js" | ||
import { unevalObject } from "./unevalObject.js" | ||
import { unevalConstructor } from "../util.js" | ||
import { unevalPrimitive } from "../primitive/index.js" | ||
import { unevalFunction } from "./unevalFunction.js" | ||
import { unevalDate } from "./unevalDate.js" | ||
import { unevalNumberObject } from "./unevalNumberObject.js" | ||
import { unevalStringObject } from "./unevalStringObject.js" | ||
import { unevalBooleanObject } from "./unevalBooleanObject.js" | ||
import { unevalError } from "./unevalError.js" | ||
import { unevalRegExp } from "./unevalRegExp.js" | ||
const unevalBoolean = (value, options = {}) => { | ||
const { depth = 0 } = options | ||
const booleanSource = unevalPrimitive(value.valueOf(), { ...options, depth: depth + 1 }) | ||
return unevalConstructor(`Boolean(${booleanSource})`, options) | ||
} | ||
const unevalError = (value, options = {}) => { | ||
const { depth = 0 } = options | ||
const messageSource = unevalPrimitive(value.message, { ...options, depth: depth + 1 }) | ||
return unevalConstructor(`${value.name}(${messageSource})`, options) | ||
} | ||
const unevalRegExp = (value) => { | ||
return value.toString() | ||
} | ||
const unevalNumber = (value, options = {}) => { | ||
const { depth = 0 } = options | ||
const numberSource = unevalPrimitive(value.valueOf(), { ...options, depth: depth + 1 }) | ||
return unevalConstructor(`Number(${numberSource})`, options) | ||
} | ||
const unevalString = (value, options) => { | ||
const { depth = 0 } = options | ||
const stringSource = unevalPrimitive(value.valueOf(), { ...options, depth: depth + 1 }) | ||
return unevalConstructor(`String(${stringSource})`, options) | ||
} | ||
const { toString } = Object.prototype | ||
const getCompositeType = (object) => { | ||
if (typeof object === "object" && Object.getPrototypeOf(object) === null) return "Object" | ||
const toStringResult = toString.call(object) | ||
// returns format is '[object ${tagName}]'; | ||
// and we want ${tagName} | ||
const tagName = toStringResult.slice("[object ".length, -1) | ||
if (tagName === "Object") { | ||
const objectConstructorName = object.constructor.name | ||
if (objectConstructorName !== "Object") { | ||
return objectConstructorName | ||
} | ||
} | ||
return tagName | ||
} | ||
const mapping = { | ||
export const compositeMap = { | ||
Array: unevalArray, | ||
Boolean: unevalBoolean, | ||
Boolean: unevalBooleanObject, | ||
Error: unevalError, | ||
Date: unevalDate, | ||
Error: unevalError, | ||
Number: unevalNumber, | ||
Function: unevalFunction, | ||
Number: unevalNumberObject, | ||
Object: unevalObject, | ||
RegExp: unevalRegExp, | ||
String: unevalString, | ||
String: unevalStringObject, | ||
} | ||
export const unevalComposite = (value, options) => { | ||
const type = getCompositeType(value) | ||
if (type in mapping) { | ||
return mapping[type](value, options) | ||
} | ||
return unevalConstructor(`${type}(${unevalObject(value, options)})`, { | ||
...options, | ||
parenthesis: false, | ||
}) | ||
} |
@@ -1,6 +0,8 @@ | ||
import { unevalConstructor, preNewLineAndIndentation, wrapNewLineAndIndentation } from "../util.js" | ||
import { unevalPrimitive } from "../primitive/index.js" | ||
import { preNewLineAndIndentation, wrapNewLineAndIndentation } from "../util.js" | ||
import { unevalConstructor } from "../unevalConstructor.js" | ||
export const unevalArray = (value, options = {}) => { | ||
const { seen = [] } = options | ||
export const unevalArray = ( | ||
value, | ||
{ seen = [], nestedUneval, compact, depth, indentUsingTab, indentSize, parenthesis, useNew }, | ||
) => { | ||
if (seen.indexOf(value) > -1) { | ||
@@ -14,13 +16,5 @@ return "Symbol.for('circular')" | ||
const j = value.length | ||
const { compact } = options | ||
const { depth = 0 } = options | ||
const nestedOptions = { | ||
...options, | ||
depth: depth + 1, | ||
seen, | ||
} | ||
while (i < j) { | ||
const valueSource = value.hasOwnProperty(i) ? unevalPrimitive(value[i], nestedOptions) : "" | ||
const valueSource = value.hasOwnProperty(i) ? nestedUneval(value[i], { seen }) : "" | ||
if (compact) { | ||
@@ -37,3 +31,7 @@ if (i === 0) { | ||
} else { | ||
valuesSource += `,${preNewLineAndIndentation(valueSource, options)}` | ||
valuesSource += `,${preNewLineAndIndentation(valueSource, { | ||
depth, | ||
indentUsingTab, | ||
indentSize, | ||
})}` | ||
} | ||
@@ -48,3 +46,3 @@ i++ | ||
} else { | ||
arraySource = wrapNewLineAndIndentation(valuesSource, options) | ||
arraySource = wrapNewLineAndIndentation(valuesSource, { depth, indentUsingTab, indentSize }) | ||
} | ||
@@ -57,3 +55,3 @@ } else { | ||
return unevalConstructor(arraySource, options) | ||
return unevalConstructor(arraySource, { parenthesis, useNew }) | ||
} |
@@ -1,9 +0,6 @@ | ||
import { unevalConstructor } from "../util.js" | ||
import { unevalPrimitive } from "../primitive/index.js" | ||
import { unevalConstructor } from "../unevalConstructor.js" | ||
export const unevalDate = (value, options = {}) => { | ||
const { depth = 0 } = options | ||
const dateSource = unevalPrimitive(value.valueOf(), { ...options, depth: depth + 1 }) | ||
return unevalConstructor(`Date(${dateSource})`, options) | ||
export const unevalDate = (value, { nestedUneval, useNew, parenthesis }) => { | ||
const dateSource = nestedUneval(value.valueOf()) | ||
return unevalConstructor(`Date(${dateSource})`, { useNew, parenthesis }) | ||
} |
@@ -1,6 +0,18 @@ | ||
import { unevalConstructor, preNewLineAndIndentation, wrapNewLineAndIndentation } from "../util.js" | ||
import { unevalPrimitive } from "../primitive/index.js" | ||
import { preNewLineAndIndentation, wrapNewLineAndIndentation } from "../util.js" | ||
import { unevalConstructor } from "../unevalConstructor.js" | ||
export const unevalObject = (value, options = {}) => { | ||
const { seen = [] } = options | ||
export const unevalObject = ( | ||
value, | ||
{ | ||
nestedUneval, | ||
seen = [], | ||
compact, | ||
depth, | ||
indentUsingTab, | ||
indentSize, | ||
objectConstructor, | ||
parenthesis, | ||
useNew, | ||
}, | ||
) => { | ||
if (seen.indexOf(value) > -1) { | ||
@@ -15,19 +27,10 @@ return "Symbol.for('circular')" | ||
const j = propertyNames.length | ||
const { depth = 0 } = options | ||
const { compact } = options | ||
const nestedOptions = { | ||
...options, | ||
depth: depth + 1, | ||
seen, | ||
} | ||
while (i < j) { | ||
const propertyName = propertyNames[i] | ||
const propertyNameAsNumber = parseInt(propertyName, 10) | ||
const propertyNameSource = unevalPrimitive( | ||
const propertyNameSource = nestedUneval( | ||
Number.isInteger(propertyNameAsNumber) ? propertyNameAsNumber : propertyName, | ||
nestedOptions, | ||
) | ||
const propertyValueSource = unevalPrimitive(value[propertyName], nestedOptions) | ||
const propertyValueSource = nestedUneval(value[propertyName], { seen }) | ||
@@ -45,3 +48,3 @@ if (compact) { | ||
`${propertyNameSource}: ${propertyValueSource}`, | ||
options, | ||
{ depth, indentUsingTab, indentSize }, | ||
)}` | ||
@@ -58,3 +61,7 @@ } | ||
} else { | ||
objectSource = `${wrapNewLineAndIndentation(propertiesSource, options)}` | ||
objectSource = `${wrapNewLineAndIndentation(propertiesSource, { | ||
depth, | ||
indentUsingTab, | ||
indentSize, | ||
})}` | ||
} | ||
@@ -65,3 +72,2 @@ } else { | ||
const { objectConstructor } = options | ||
if (objectConstructor) { | ||
@@ -73,3 +79,3 @@ objectSource = `Object({${objectSource}})` | ||
return unevalConstructor(objectSource, options) | ||
return unevalConstructor(objectSource, { parenthesis, useNew }) | ||
} |
@@ -1,69 +0,12 @@ | ||
import { quote } from "../util.js" | ||
import { unevalComposite } from "../composite/index.js" | ||
import { unevalBoolean } from "./unevalBoolean.js" | ||
import { unevalNull } from "./unevalNull.js" | ||
import { unevalNumber } from "./unevalNumber.js" | ||
import { unevalString } from "./unevalString.js" | ||
import { unevalSymbol } from "./unevalSymbol.js" | ||
import { unevalUndefined } from "./unevalUndefined.js" | ||
const unevalBoolean = (value) => value.toString() | ||
const unevalFunction = (value, { showFunctionBody, parenthesis, depth }) => { | ||
let functionSource | ||
if (showFunctionBody) { | ||
functionSource = value.toString() | ||
} else { | ||
const isArrowFunction = value.prototype === undefined | ||
const head = isArrowFunction ? "() =>" : `function ${depth === 0 ? value.name : ""}()` | ||
functionSource = `${head} {/* hidden */}` | ||
} | ||
if (parenthesis) { | ||
return `(${functionSource})` | ||
} | ||
return functionSource | ||
} | ||
const unevalNull = () => "null" | ||
const unevalNumber = (value) => { | ||
return Object.is(value, -0) ? "-0" : value.toString() | ||
} | ||
const unevalString = (value, { singleQuote }) => { | ||
const quotedValue = quote(value) | ||
return singleQuote ? `'${quotedValue}'` : `"${quotedValue}"` | ||
} | ||
const unevalSymbol = (value, options) => { | ||
const toStringResult = value.toString() | ||
const openingParenthesisIndex = toStringResult.indexOf("(") | ||
const closingParenthesisIndex = toStringResult.indexOf(")") | ||
const symbolDescription = toStringResult.slice( | ||
openingParenthesisIndex + 1, | ||
closingParenthesisIndex, | ||
) | ||
const symbolDescriptionSource = symbolDescription ? unevalString(symbolDescription, options) : "" | ||
const symbolSource = `Symbol(${symbolDescriptionSource})` | ||
if (options.parenthesis) { | ||
return `${symbolSource}` | ||
} | ||
return symbolSource | ||
} | ||
const unevalUndefined = () => "undefined" | ||
const getPrimitiveType = (value) => { | ||
if (value === null) { | ||
return "null" | ||
} | ||
if (value === undefined) { | ||
return "undefined" | ||
} | ||
return typeof value | ||
} | ||
const mappings = { | ||
export const primitiveMap = { | ||
boolean: unevalBoolean, | ||
function: unevalFunction, | ||
null: unevalNull, | ||
number: unevalNumber, | ||
object: unevalComposite, | ||
string: unevalString, | ||
@@ -73,31 +16,1 @@ symbol: unevalSymbol, | ||
} | ||
export const unevalPrimitive = ( | ||
value, | ||
{ | ||
parenthesis = false, | ||
singleQuote = false, | ||
useNew = false, | ||
objectConstructor = false, | ||
compact = false, | ||
showFunctionBody = false, | ||
indentUsingTab = false, | ||
indentSize = 2, | ||
depth = 0, // internal, not meant to be used in public api | ||
...remainingProps | ||
} = {}, | ||
) => { | ||
const type = getPrimitiveType(value) | ||
return mappings[type](value, { | ||
parenthesis, | ||
singleQuote, | ||
useNew, | ||
objectConstructor, | ||
compact, | ||
showFunctionBody, | ||
indentUsingTab, | ||
indentSize, | ||
depth, | ||
...remainingProps, | ||
}) | ||
} |
@@ -1,3 +0,53 @@ | ||
// https://github.com/jsenv/core/blob/959e76068b62c23d7047f6a8c7a3d6582ac25177/src/api/util/uneval.js | ||
/* eslint-disable import/max-dependencies */ | ||
import { valueToType } from "./valueToType.js" | ||
import { primitiveMap } from "./primitive/index.js" | ||
import { compositeMap } from "./composite/index.js" | ||
import { unevalConstructor } from "./unevalConstructor.js" | ||
import { unevalObject } from "./composite/unevalObject.js" | ||
export { unevalPrimitive as uneval } from "./primitive/index.js" | ||
export const uneval = ( | ||
value, | ||
{ | ||
parenthesis = false, | ||
singleQuote = false, | ||
useNew = false, | ||
objectConstructor = false, | ||
compact = false, | ||
showFunctionBody = false, | ||
indentUsingTab = false, | ||
indentSize = 2, | ||
} = {}, | ||
) => { | ||
const scopedUneval = (scopedValue, scopedOptions) => { | ||
const { primitiveType, compositeType } = valueToType(scopedValue) | ||
const options = { | ||
...scopedOptions, | ||
nestedUneval: (nestedValue, nestedOptions = {}) => { | ||
return scopedUneval(nestedValue, { | ||
...scopedOptions, | ||
depth: scopedOptions.depth + 1, | ||
...nestedOptions, | ||
}) | ||
}, | ||
} | ||
if (primitiveType) return primitiveMap[primitiveType](scopedValue, options) | ||
if (compositeType in compositeMap) return compositeMap[compositeType](scopedValue, options) | ||
return unevalConstructor(`${compositeType}(${unevalObject(scopedValue, options)})`, { | ||
...options, | ||
parenthesis: false, | ||
}) | ||
} | ||
return scopedUneval(value, { | ||
parenthesis, | ||
singleQuote, | ||
useNew, | ||
objectConstructor, | ||
compact, | ||
showFunctionBody, | ||
indentUsingTab, | ||
indentSize, | ||
depth: 0, | ||
}) | ||
} |
@@ -30,14 +30,12 @@ // https://github.com/joliss/js-string-escape/blob/master/index.js | ||
export const unevalConstructor = (value, { parenthesis, useNew }) => { | ||
let formattedString = value | ||
export const preNewLineAndIndentation = (value, { depth, indentUsingTab, indentSize }) => { | ||
return `${newLineAndIndent({ | ||
count: depth + 1, | ||
useTabs: indentUsingTab, | ||
size: indentSize, | ||
})}${value}` | ||
} | ||
if (parenthesis) { | ||
formattedString = `(${value})` | ||
} | ||
if (useNew) { | ||
formattedString = `new ${formattedString}` | ||
} | ||
return formattedString | ||
const postNewLineAndIndentation = ({ depth, indentUsingTab, indentSize }) => { | ||
return newLineAndIndent({ count: depth, useTabs: indentUsingTab, size: indentSize }) | ||
} | ||
@@ -54,16 +52,8 @@ | ||
export const preNewLineAndIndentation = (value, { depth = 0, indentUsingTab, indentSize }) => { | ||
return `${newLineAndIndent({ | ||
count: depth + 1, | ||
useTabs: indentUsingTab, | ||
size: indentSize, | ||
})}${value}` | ||
export const wrapNewLineAndIndentation = (value, { depth, indentUsingTab, indentSize }) => { | ||
return `${preNewLineAndIndentation(value, { | ||
depth, | ||
indentUsingTab, | ||
indentSize, | ||
})}${postNewLineAndIndentation({ depth, indentUsingTab, indentSize })}` | ||
} | ||
const postNewLineAndIndentation = ({ depth = 0, indentUsingTab, indentSize }) => { | ||
return newLineAndIndent({ count: depth, useTabs: indentUsingTab, size: indentSize }) | ||
} | ||
export const wrapNewLineAndIndentation = (value, options) => { | ||
return `${preNewLineAndIndentation(value, options)}${postNewLineAndIndentation(options)}` | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
32
1716
139065
13
22
1
1