# All files liner.js

100% Statements 14/14
100% Branches 8/8
100% Functions 1/1
100% Lines 14/14

Press n or j to go to the next uncovered block, b, p or k for the previous block.

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    184x
    34x
    34x
    34x
    34x
    859x
    859x
    3x
    856x
    3x
    853x
    203x
    203x

    34x

     module.exports = function liner(tokens) {
      let line = []
      let result = [line]
      let brackets = 0
      for (let token of tokens) {
        line.push(token)
        if (token[0] === '(') {
          brackets += 1
        } else if (token[0] === ')') {
          brackets -= 1
        } else if (token[0] === 'newline' && brackets === 0) {
          line = []
          result.push(line)
        }
      }
      return result
    }