mirror of
https://github.com/hanzoai/es5-ext.git
synced 2026-09-24 16:58:43 +00:00
feat: improve new lines representation
This commit is contained in:
@@ -19,5 +19,5 @@ module.exports = function (t, a) {
|
||||
if (typeof Symbol === "function") a(t(Symbol()), "Symbol()");
|
||||
a(t(Object.create(null)), "<non-stringifiable value>");
|
||||
a(t(repeat.call("a", 300)), repeat.call("a", 99) + "…");
|
||||
a(t("mar\ntoo\nfar"), "mar too far");
|
||||
a(t("mar\ntoo\nfar"), "mar\\ntoo\\nfar");
|
||||
};
|
||||
|
||||
@@ -9,6 +9,8 @@ module.exports = function (value) {
|
||||
// Trim if too long
|
||||
if (string.length > 100) string = string.slice(0, 99) + "…";
|
||||
// Replace eventual new lines
|
||||
string = string.replace(reNewLine, " ");
|
||||
string = string.replace(reNewLine, function (char) {
|
||||
return JSON.stringify(char).slice(1, -1);
|
||||
});
|
||||
return string;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user