# All files / src/parser/grammar helpers.js

94.44% Statements 17/18
100% Branches 4/4
87.5% Functions 7/8
100% Lines 14/14

    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
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    3624x
    24x

    97x
    4256x
    24x
    45130x

    24x

    24x
    6909x
    36292x
    4428x

    31864x

    24x
    2695x

     import compose from '../../utils/compose';
    import { extendNode } from '../../utils/extend-node';

    export { extendNode };

    export const nth = n => d => d[n];
    export const nuller = () => null;
    export const nonEmpty = d => {
      return Array.isArray(d) ? !!d.length : d != null;
    };
    export const add = d => `${d[0]}${d[1]}`;

    export const flatten = d =>
      d.reduce((acc, v) => {
        if (Array.isArray(v)) {
          return acc.concat(v);
        }

        return acc.concat(v);
      }, []);

    export const drop = d => {
      return d.filter(nonEmpty);
    };

    export default {
      nth,
      nuller,
      nonEmpty,
      add,
      flatten,
      compose,
      drop,
      extendNode,
    };