Code coverage report for lib/RegExpMatch.js

Statements: 70% (21 / 30)      Branches: 0% (0 / 2)      Functions: 60% (6 / 10)      Lines: 70% (21 / 30)      Ignored: none     

All files » lib/ » RegExpMatch.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 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128    1   1   1   1   1         1 1 8   8 8 8   8 24                     1                           12                                                             24                           4                       16       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 _Object$defineProperty = require('babel-runtime/core-js/object/define-property')['default'];
 
var _Symbol$iterator = require('babel-runtime/core-js/symbol/iterator')['default'];
 
Object.defineProperty(exports, '__esModule', {
    value: true
});
/** @class RegExpMatch 
* @param result */
var RegExpMatch = (function () {
    function RegExpMatch(result) {
        _classCallCheck(this, RegExpMatch);
 
        Object.defineProperty(this, 'groupCount', { value: result.length - 1 });
        Object.defineProperty(this, 'start', { value: result.index });
        Object.defineProperty(this, 'input', { value: result.input });
 
        for (var i = 0; i <= result.length; i++) {
            _Object$defineProperty(this, String(i), { value: result[i] });
        }
    }
 
    /**
     * The match of the pattern.
     
    * @memberof RegExpMatch 
    * @instance 
    * @member {string} match */
 
    _createClass(RegExpMatch, [{
        key: 'group',
 
        /**
         * Returns the string matched by the given group.
         *
         * If group is 0, returns the match of the pattern.
         
        * @memberof RegExpMatch 
        * @instance 
        * @method group 
        * @param {number} group 
        * @returns {string} */
        value: function group(_group) {
            return this[_group];
        }
    }, {
        key: _Symbol$iterator,
        /** @memberof RegExpMatch 
        * @instance */value: function value() {
            var i = 0;
            return {
                next: /** @function */function next() {
                    return { value: this[i], done: ++i > this.length };
                }
            };
        }
    }, {
        key: 'toString',
        /** @memberof RegExpMatch 
        * @instance 
        * @method toString */value: function toString() {
            var str = 'match= "' + this.match + '", start= ' + this.start + ', groupCount= ' + this.groupCount;
 
            if (this.groupCount) {
                for (var i = 1; i < this.groupCount; i++) {
                    str += ', group' + i + '= "' + this[i] + '"';
                }
            }
 
            return str;
        }
    }, {
        key: 'match',
        get: function get() {
            return this[0];
        }
    }, {
        key: 'index',
        /** @memberof RegExpMatch 
        * @instance 
        * @member {number} index */get: function get() {
            return this.start;
        }
    }, {
        key: 'length',
        /** @memberof RegExpMatch 
        * @instance 
        * @member {number} length */get: function get() {
            return this.groupCount;
        }
 
        /**
         * The index in the string after the last character of the match.
         
        * @memberof RegExpMatch 
        * @instance 
        * @member {number} end */
    }, {
        key: 'end',
        get: function get() {
            return this.start + this.match.length;
        }
    }]);
 
    return RegExpMatch;
})();
 
exports['default'] = RegExpMatch;
module.exports = exports['default'];
 
/**
 * Returns the number of captured groups in the match.
 */
 
/**
 * The string on which this match was computed.
 */
 
/**
 * The index in the string where the match starts.
 */
//# sourceMappingURL=RegExpMatch.js.map