acuminous/yadda

View on GitHub
lib/parsers/StepParser.js

Summary

Maintainability
A
0 mins
Test Coverage
A
100%
'use strict';

var $ = require('../Array');

var StepParser = function () {
  var NON_BLANK_REGEX = /[^\s]/;

  this.parse = function (text, next) {
    var steps = split(text).find_all(non_blanks);
    return (next && next(steps)) || steps;
  };

  var split = function (text) {
    return $(text.split(/\n/));
  };

  var non_blanks = function (text) {
    return text && NON_BLANK_REGEX.test(text);
  };
};

module.exports = StepParser;