You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

to-short-string-representation.js 413B

12345678910111213141516
  1. "use strict";
  2. var safeToString = require("./safe-to-string");
  3. var reNewLine = /[\n\r\u2028\u2029]/g;
  4. module.exports = function (value) {
  5. var string = safeToString(value);
  6. // Trim if too long
  7. if (string.length > 100) string = string.slice(0, 99) + "…";
  8. // Replace eventual new lines
  9. string = string.replace(reNewLine, function (char) {
  10. return JSON.stringify(char).slice(1, -1);
  11. });
  12. return string;
  13. };