wooorm / comma-separated-tokens
Showing 1 of 1 files from the diff.

@@ -3,17 +3,13 @@
Loading
3 3
exports.parse = parse
4 4
exports.stringify = stringify
5 5
6 -
var comma = ','
7 -
var space = ' '
8 -
var empty = ''
9 -
10 6
// Parse comma-separated tokens to an array.
11 7
function parse(value) {
12 -
  var values = []
13 -
  var input = String(value || empty)
14 -
  var index = input.indexOf(comma)
15 -
  var lastIndex = 0
16 -
  var end = false
8 +
  var tokens = []
9 +
  var input = String(value || '')
10 +
  var index = input.indexOf(',')
11 +
  var start = 0
12 +
  var end
17 13
  var token
18 14
19 15
  while (!end) {
@@ -22,17 +18,17 @@
Loading
22 18
      end = true
23 19
    }
24 20
25 -
    token = input.slice(lastIndex, index).trim()
21 +
    token = input.slice(start, index).trim()
26 22
27 23
    if (token || !end) {
28 -
      values.push(token)
24 +
      tokens.push(token)
29 25
    }
30 26
31 -
    lastIndex = index + 1
32 -
    index = input.indexOf(comma, lastIndex)
27 +
    start = index + 1
28 +
    index = input.indexOf(',', start)
33 29
  }
34 30
35 -
  return values
31 +
  return tokens
36 32
}
37 33
38 34
// Compile an array to comma-separated tokens.
@@ -40,13 +36,17 @@
Loading
40 36
// `options.padRight` (default: `false`) pads a space to the right of each token.
41 37
function stringify(values, options) {
42 38
  var settings = options || {}
43 -
  var left = settings.padLeft === false ? empty : space
44 -
  var right = settings.padRight ? space : empty
45 39
46 40
  // Ensure the last empty entry is seen.
47 -
  if (values[values.length - 1] === empty) {
48 -
    values = values.concat(empty)
41 +
  if (values[values.length - 1] === '') {
42 +
    values = values.concat('')
49 43
  }
50 44
51 -
  return values.join(right + comma + left).trim()
45 +
  return values
46 +
    .join(
47 +
      (settings.padRight ? ' ' : '') +
48 +
        ',' +
49 +
        (settings.padLeft === false ? '' : ' ')
50 +
    )
51 +
    .trim()
52 52
}
Files Coverage
index.js 100.00%
Project Totals (1 files) 100.00%
77.1
lts/dubnium=/dubnium
TRAVIS_OS_NAME=linux
77.2
node=
TRAVIS_OS_NAME=linux

No yaml found.

Create your codecov.yml to customize your Codecov experience

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