# All files / src/parsers pipe.js

100% Statements 5/5
100% Branches 0/0
100% Functions 3/3
100% Lines 5/5

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
    18
    19
    20
    21
    22
    23
    24
    25

    19x
    8x
    8x

    542x
    94x

     // @flow

    import P from 'parsimmon'

    import type { NodeType } from '../types'

    const PipeParser = P.lazy((): mixed => {
      const TernaryParser = require('./ternary').default
      return TernaryParser.sepBy1(P.regexp(/\s*\|\s*/)).map(
        (value: Array<NodeType>): NodeType =>
          value.slice(1).reduce(
            (a: NodeType, b: NodeType): NodeType => ({
              name: 'pipe',
              value: {
                left: a,
                right: b
              }
            }),
            value[0]
          )
      )
    })

    export default PipeParser