function createErrDiff()

in src/js/node/assert.ts [416:653]


    function createErrDiff(actual, expected, operator) {
      var other = "",
        res = "",
        lastPos = 0,
        end = "",
        skipped = !1,
        actualInspected = inspectValue(actual),
        actualLines = actualInspected.split(`
`),
        expectedLines = inspectValue(expected).split(`
`),
        i = 0,
        indicator = "";
      if (
        (operator === "strictEqual" &&
          _typeof(actual) === "object" &&
          _typeof(expected) === "object" &&
          actual !== null &&
          expected !== null &&
          (operator = "strictEqualObject"),
        actualLines.length === 1 && expectedLines.length === 1 && actualLines[0] !== expectedLines[0])
      ) {
        var inputLength = actualLines[0].length + expectedLines[0].length;
        if (inputLength <= kMaxShortLength) {
          if (
            (_typeof(actual) !== "object" || actual === null) &&
            (_typeof(expected) !== "object" || expected === null) &&
            (actual !== 0 || expected !== 0)
          )
            return (
              "".concat(
                kReadableOperator[operator],
                `

`,
              ) +
              "".concat(actualLines[0], " !== ").concat(
                expectedLines[0],
                `
`,
              )
            );
        } else if (operator !== "strictEqualObject") {
          var maxLength = process.stderr && process.stderr.isTTY ? process.stderr.columns : 80;
          if (inputLength < maxLength) {
            for (; actualLines[0][i] === expectedLines[0][i]; ) i++;
            i > 2 &&
              ((indicator = `
  `.concat(repeat(" ", i), "^")),
              (i = 0));
          }
        }
      }
      for (
        var a = actualLines[actualLines.length - 1], b = expectedLines[expectedLines.length - 1];
        a === b &&
        (i++ < 2
          ? (end = `
  `
              .concat(a)
              .concat(end))
          : (other = a),
        actualLines.pop(),
        expectedLines.pop(),
        !(actualLines.length === 0 || expectedLines.length === 0));

      )
        (a = actualLines[actualLines.length - 1]), (b = expectedLines[expectedLines.length - 1]);
      var maxLines = Math.max(actualLines.length, expectedLines.length);
      if (maxLines === 0) {
        var _actualLines = actualInspected.split(`
`);
        if (_actualLines.length > 30)
          for (_actualLines[26] = "".concat(blue, "...").concat(white); _actualLines.length > 27; ) _actualLines.pop();
        return ""
          .concat(
            kReadableOperator.notIdentical,
            `

`,
          )
          .concat(
            _actualLines.join(`
`),
            `
`,
          );
      }
      i > 3 &&
        ((end = `
`
          .concat(blue, "...")
          .concat(white)
          .concat(end)),
        (skipped = !0)),
        other !== "" &&
          ((end = `
  `
            .concat(other)
            .concat(end)),
          (other = ""));
      var printedLines = 0,
        msg =
          kReadableOperator[operator] +
          `
`
            .concat(green, "+ actual")
            .concat(white, " ")
            .concat(red, "- expected")
            .concat(white),
        skippedMsg = " ".concat(blue, "...").concat(white, " Lines skipped");
      for (i = 0; i < maxLines; i++) {
        var cur = i - lastPos;
        if (actualLines.length < i + 1)
          cur > 1 &&
            i > 2 &&
            (cur > 4
              ? ((res += `
`
                  .concat(blue, "...")
                  .concat(white)),
                (skipped = !0))
              : cur > 3 &&
                ((res += `
  `.concat(expectedLines[i - 2])),
                printedLines++),
            (res += `
  `.concat(expectedLines[i - 1])),
            printedLines++),
            (lastPos = i),
            (other += `
`
              .concat(red, "-")
              .concat(white, " ")
              .concat(expectedLines[i])),
            printedLines++;
        else if (expectedLines.length < i + 1)
          cur > 1 &&
            i > 2 &&
            (cur > 4
              ? ((res += `
`
                  .concat(blue, "...")
                  .concat(white)),
                (skipped = !0))
              : cur > 3 &&
                ((res += `
  `.concat(actualLines[i - 2])),
                printedLines++),
            (res += `
  `.concat(actualLines[i - 1])),
            printedLines++),
            (lastPos = i),
            (res += `
`
              .concat(green, "+")
              .concat(white, " ")
              .concat(actualLines[i])),
            printedLines++;
        else {
          var expectedLine = expectedLines[i],
            actualLine = actualLines[i],
            divergingLines =
              actualLine !== expectedLine && (!endsWith(actualLine, ",") || actualLine.slice(0, -1) !== expectedLine);
          divergingLines &&
            endsWith(expectedLine, ",") &&
            expectedLine.slice(0, -1) === actualLine &&
            ((divergingLines = !1), (actualLine += ",")),
            divergingLines
              ? (cur > 1 &&
                  i > 2 &&
                  (cur > 4
                    ? ((res += `
`
                        .concat(blue, "...")
                        .concat(white)),
                      (skipped = !0))
                    : cur > 3 &&
                      ((res += `
  `.concat(actualLines[i - 2])),
                      printedLines++),
                  (res += `
  `.concat(actualLines[i - 1])),
                  printedLines++),
                (lastPos = i),
                (res += `
`
                  .concat(green, "+")
                  .concat(white, " ")
                  .concat(actualLine)),
                (other += `
`
                  .concat(red, "-")
                  .concat(white, " ")
                  .concat(expectedLine)),
                (printedLines += 2))
              : ((res += other),
                (other = ""),
                (cur === 1 || i === 0) &&
                  ((res += `
  `.concat(actualLine)),
                  printedLines++));
        }
        if (printedLines > 20 && i < maxLines - 2)
          return (
            ""
              .concat(msg)
              .concat(
                skippedMsg,
                `
`,
              )
              .concat(
                res,
                `
`,
              )
              .concat(blue, "...")
              .concat(white)
              .concat(
                other,
                `
`,
              ) + "".concat(blue, "...").concat(white)
          );
      }
      return ""
        .concat(msg)
        .concat(
          skipped ? skippedMsg : "",
          `
`,
        )
        .concat(res)
        .concat(other)
        .concat(end)
        .concat(indicator);
    }