lib/v8-log-to-ticks.js
function fixLines (line) {
  // Node 11+ are fine
  if (nodeMajorV > 10) return line

  // Work around a bug in Node 10's V8 --preprocess -j that breaks strings containing \\
  if (nodeMajorV === 10) {
    // Look for backslashes that aren't escaping a unicode character code, like \\u01a2
    // Small risk of false positives e.g. is C:\\Users\\u2bfab\\ unicode, or a U2 fan?
    // So, restrict to basic multilingual (4 char) only. No hieroglyphs or ancient Mayan.
    const startPath = line.search(/\\(?!u[0-9A-Fa-f]{4})/)
    if (startPath === -1) return line

    // Replace any \\ that's not part of a unicode escape character
    const replaceRegex = /\\(?!u[0-9A-Fa-f]{4})/g
    // \u005c is the unicode escape for the \ char
    return line.slice(0, startPath) + line.slice(startPath).replace(replaceRegex, '\\u005c')
  }

  if (nodeMajorV < 10) {
    // In regexs, Node 8 (and 9) hard-escapes unicode and doubles \\ to \\\\
    if (!line.match(/^code-creation,RegExp/)) return line

    // Normal buffer decoding, String.normalize() etc doesn't work here, brute force needed
    const escapedUnicode = line.match(/(\\u[0-9A-Fa-f]{4})+/g)
    if (escapedUnicode) {
      for (const match of escapedUnicode) {
        line = line.replace(match, JSON.parse(`"${match}"`))
      }
    }
    return line.replace(/\\\\/g, '\\')
  }
}
function fixLines (line) {
  // Node 11+ are fine
  if (nodeMajorV > 10) return line

  // Work around a bug in Node 10's V8 --preprocess -j that breaks strings containing \\
  if (nodeMajorV === 10) {
    // Look for backslashes that aren't escaping a unicode character code, like \\u01a2
    // Small risk of false positives e.g. is C:\\Users\\u2bfab\\ unicode, or a U2 fan?
    // So, restrict to basic multilingual (4 char) only. No hieroglyphs or ancient Mayan.
    const startPath = line.search(/\\(?!u[0-9A-Fa-f]{4})/)
    if (startPath === -1) return line

    // Replace any \\ that's not part of a unicode escape character
    const replaceRegex = /\\(?!u[0-9A-Fa-f]{4})/g
    // \u005c is the unicode escape for the \ char
    return line.slice(0, startPath) + line.slice(startPath).replace(replaceRegex, '\\u005c')
  }

  if (nodeMajorV < 10) {
    // In regexs, Node 8 (and 9) hard-escapes unicode and doubles \\ to \\\\
    if (!line.match(/^code-creation,RegExp/)) return line

    // Normal buffer decoding, String.normalize() etc doesn't work here, brute force needed
    const escapedUnicode = line.match(/(\\u[0-9A-Fa-f]{4})+/g)
    if (escapedUnicode) {
      for (const match of escapedUnicode) {
        line = line.replace(match, JSON.parse(`"${match}"`))
      }
    }
    return line.replace(/\\\\/g, '\\')
  }
}
function fixLines ( line ) { // Node 11+ are fine if ( nodeMajorV > 10 ) return line // Work around a bug in Node 10's V8 --preprocess -j that breaks strings containing \\ if ( nodeMajorV === 10 ) { // Look for backslashes that aren't escaping a unicode character code, like \\u01a2 // Small risk of false positives e.g. is C:\\Users\\u2bfab\\ unicode, or a U2 fan? // So, restrict to basic multilingual (4 char) only. No hieroglyphs or ancient Mayan. const startPath = line . search ( / \\(?!u[0-9A-Fa-f]{4}) / ) if ( startPath === - 1 ) return line // Replace any \\ that's not part of a unicode escape character const replaceRegex = / \\(?!u[0-9A-Fa-f]{4}) / g // \u005c is the unicode escape for the \ char return line . slice ( 0 , startPath ) + line . slice ( startPath ) . replace ( replaceRegex , '\\u005c' ) } if ( nodeMajorV < 10 ) { // In regexs, Node 8 (and 9) hard-escapes unicode and doubles \\ to \\\\ if ( ! line . match ( / ^code-creation,RegExp / ) ) return line // Normal buffer decoding, String.normalize() etc doesn't work here, brute force needed const escapedUnicode = line . match ( / (\\u[0-9A-Fa-f]{4})+ / g ) if ( escapedUnicode ) { for ( const match of escapedUnicode ) { line = line . replace ( match , JSON . parse ( ` ${ match } ` ) ) } } return line . replace ( / \\\\ / g , '\\' ) } }
Fixes node-version-specific issues with isolate log text
Fixes node - version - specific issues with isolate log text