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

@@ -1,5 +1,5 @@
Loading
1 -
const SPACE = 32
2 -
const TAB = 9
1 +
const tab = 9 /* `\t` */
2 +
const space = 32 /* ` ` */
3 3
4 4
/**
5 5
 * Remove initial and final spaces and tabs at the line breaks in `value`.
@@ -20,7 +20,7 @@
Loading
20 20
21 21
  while (match) {
22 22
    lines.push(
23 -
      trimLine(source.slice(last, match.index), last !== 0, true),
23 +
      trimLine(source.slice(last, match.index), last > 0, true),
24 24
      match[0]
25 25
    )
26 26
@@ -28,24 +28,29 @@
Loading
28 28
    match = search.exec(source)
29 29
  }
30 30
31 -
  lines.push(trimLine(source.slice(last), last !== 0, false))
31 +
  lines.push(trimLine(source.slice(last), last > 0, false))
32 32
33 33
  return lines.join('')
34 34
}
35 35
36 36
/**
37 37
 * @param {string} value
38 +
 *   Line to trim.
38 39
 * @param {boolean} start
40 +
 *   Whether to trim the start of the line.
39 41
 * @param {boolean} end
42 +
 *   Whether to trim the end of the line.
40 43
 * @returns {string}
44 +
 *   Trimmed line.
41 45
 */
42 46
function trimLine(value, start, end) {
43 47
  let startIndex = 0
44 48
  let endIndex = value.length
49 +
45 50
  if (start) {
46 51
    let code = value.codePointAt(startIndex)
47 52
48 -
    while (code === SPACE || code === TAB) {
53 +
    while (code === tab || code === space) {
49 54
      startIndex++
50 55
      code = value.codePointAt(startIndex)
51 56
    }
@@ -54,7 +59,7 @@
Loading
54 59
  if (end) {
55 60
    let code = value.codePointAt(endIndex - 1)
56 61
57 -
    while (code === SPACE || code === TAB) {
62 +
    while (code === tab || code === space) {
58 63
      endIndex--
59 64
      code = value.codePointAt(endIndex - 1)
60 65
    }
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