const showNumber = (lineInfo) => { const first = lineInfo.line[0]; return first === ' ' || first === '@' || first === '-' || first === '+'; } const construct = (data) => { const diffs = data.diffs let result = ` ` for(let lineInfo of diffs.lines) { result += ` ` } result += `
Old    ${diffs.old}}
   New ${diffs.new}
${showNumber(lineInfo) ? lineInfo['num-old'] : '  '} ${showNumber(lineInfo) ? lineInfo['num-new'] : '  '}
${lineInfo.line}
` return result; } onmessage = function(e) { const result = construct(e.data); postMessage(result) }