wooorm / trim-lines
Showing 1 of 2 files from the diff.
Other files ignored by Codecov
test.js has changed.

@@ -17,7 +17,7 @@
Loading
17 17
18 18
  while (match) {
19 19
    lines.push(
20 -
      trimLine(source.slice(last, match.index), last === 0, false),
20 +
      trimLine(source.slice(last, match.index), last !== 0, true),
21 21
      match[0]
22 22
    )
23 23
@@ -25,7 +25,7 @@
Loading
25 25
    match = search.exec(source)
26 26
  }
27 27
28 -
  lines.push(trimLine(source.slice(last), last === 0, true))
28 +
  lines.push(trimLine(source.slice(last), last !== 0, false))
29 29
30 30
  return lines.join('')
31 31
}
@@ -37,20 +37,25 @@
Loading
37 37
 * @returns {string}
38 38
 */
39 39
function trimLine(value, start, end) {
40 -
  if (!start) {
41 -
    value = value.replace(/^[ \t]+/, '')
40 +
  let startIndex = 0
41 +
  let endIndex = value.length
42 +
  if (start) {
43 +
    let code = value.codePointAt(startIndex)
44 +
45 +
    while (code === 9 || code === 32) {
46 +
      startIndex++
47 +
      code = value.codePointAt(startIndex)
48 +
    }
42 49
  }
43 50
44 -
  if (!end) {
45 -
    let endIndex = value.length - 1
46 -
    let char = value.charAt(endIndex)
47 -
    while (char === ' ' || char === '\t') {
51 +
  if (end) {
52 +
    let code = value.codePointAt(endIndex - 1)
53 +
54 +
    while (code === 9 || code === 32) {
48 55
      endIndex--
49 -
      char = value.charAt(endIndex)
56 +
      code = value.codePointAt(endIndex - 1)
50 57
    }
51 -
52 -
    value = value.slice(0, endIndex + 1)
53 58
  }
54 59
55 -
  return value
60 +
  return endIndex > startIndex ? value.slice(startIndex, endIndex) : ''
56 61
}
Files Coverage
index.js 100.00%
Project Totals (1 files) 100.00%
Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file. The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files. The size and color of each slice is representing the number of statements and the coverage, respectively.
Grid
Each block represents a single file in the project. The size and color of each block is represented by the number of statements and the coverage, respectively.
Loading