feat: improve new lines representation

This commit is contained in:
Mariusz Nowak
2017-08-18 12:38:12 +02:00
parent 6842d06755
commit 860fe8b613
2 changed files with 4 additions and 2 deletions
+1 -1
View File
@@ -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");
};
+3 -1
View File
@@ -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;
};