Code coverage report for lib/MultiRegExpIterable.js

Statements: 81.25% (26 / 32)      Branches: 60% (6 / 10)      Functions: 50% (3 / 6)      Lines: 81.25% (26 / 32)      Ignored: none     

All files » lib/ » MultiRegExpIterable.js
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 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92    1   1   1   1   1       1   1   1   1           1 1 2   2   2 2 2     1           6   6 4   2     6 6                                                                   1     1 1  
'use strict';
 
var _createClass = require('babel-runtime/helpers/create-class')['default'];
 
var _classCallCheck = require('babel-runtime/helpers/class-call-check')['default'];
 
var _Symbol$iterator = require('babel-runtime/core-js/symbol/iterator')['default'];
 
var _interopRequireDefault = require('babel-runtime/helpers/interop-require-default')['default'];
 
Object.defineProperty(exports, '__esModule', {
    value: true
});
 
var _MultiRegExp = require('./MultiRegExp');
 
var _MultiRegExp2 = _interopRequireDefault(_MultiRegExp);
 
var _RegExpMatch = require('./RegExpMatch');
 
var _RegExpMatch2 = _interopRequireDefault(_RegExpMatch);
 
/** @class MultiRegExpIterable 
* @param {MultiRegExp} multiRegExp 
* @param {string} string 
* @param {number} [start=0] */
var MultiRegExpIterable = (function () {
    function MultiRegExpIterable(multiRegExp, string) {
        var start = arguments.length <= 2 || arguments[2] === undefined ? 0 : arguments[2];
 
        _classCallCheck(this, MultiRegExpIterable);
 
        this._multiRegExp = multiRegExp;
        this._string = string;
        this._index = start;
    }
 
    _createClass(MultiRegExpIterable, [{
        key: 'next',
        /** @memberof MultiRegExpIterable 
        * @instance 
        * @method next 
        * @returns {RegExpMatch} */value: function next() {
            var match = this._multiRegExp.findMatch(this._string, this._index);
 
            if (match !== null) {
                this._index = match.start === match.end ? match.start + 1 : match.end;
            } else {
                this._index = 0;
            }
 
            this._current = match;
            return match;
        }
 
        /**
         * @method @@iterator
         * @returns {{next: Function}}
         
        * @memberof MultiRegExpIterable 
        * @instance */
    }, {
        key: _Symbol$iterator,
        value: function value() {
            var _this = this;
 
            this._index = 0;
            return {
                next: function next() {
                    var match = _this.next();
                    return {
                        value: match === null ? undefined : match,
                        done: match === null
                    };
                }
            };
        }
    }, {
        key: 'current',
        /** @memberof MultiRegExpIterable 
        * @instance 
        * @member {RegExpMatch} current */get: function get() {
            return this._current;
        }
    }]);
 
    return MultiRegExpIterable;
})();
 
exports['default'] = MultiRegExpIterable;
module.exports = exports['default'];
//# sourceMappingURL=MultiRegExpIterable.js.map