all files / TypeScript.NET/dist/commonjs/System/Collections/Enumeration/ IndexEnumerator.js

28.57% Statements 14/49
11.76% Branches 6/51
25% Functions 2/8
33.33% Lines 10/30
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                                                                                     
/*!
 * @author electricessence / https://github.com/electricessence/
 * Licensing: MIT https://github.com/electricessence/TypeScript.NET/blob/master/LICENSE.md
 */
'use strict';
 
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
 
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
 
function _inherits(subClass, superClass) { Iif (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); Eif (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
 
var EnumeratorBase_1 = require('./EnumeratorBase');
 
var IndexEnumerator = function (_EnumeratorBase_1$def) {
    _inherits(IndexEnumerator, _EnumeratorBase_1$def);
 
    function IndexEnumerator(sourceFactory) {
        _classCallCheck(this, IndexEnumerator);
 
        var source;
        return _possibleConstructorReturn(this, Object.getPrototypeOf(IndexEnumerator).call(this, function () {
            source = sourceFactory();
            if (source && source.source) {
                if (source.length < 0) throw new Error("length must be zero or greater");
                if (source.length && source.step === 0) throw new Error("Invalid IndexEnumerator step value (0).");
                var pointer = source.pointer;
                if (!pointer) source.pointer = 0;else if (pointer != Math.floor(pointer)) throw new Error("Invalid IndexEnumerator pointer value (" + pointer + ") has decimal.");
                source.pointer = pointer;
                var step = source.step;
                if (!step) source.step = 1;else if (step != Math.floor(step)) throw new Error("Invalid IndexEnumerator step value (" + step + ") has decimal.");
                source.step = step;
            }
        }, function (yielder) {
            var len = source && source.source ? source.length : 0;
            if (!len || isNaN(len)) return yielder.yieldBreak();
            var current = source.pointer;
            source.pointer += source.step;
            return current < len && current >= 0 ? yielder.yieldReturn(source.source[current]) : yielder.yieldBreak();
        }, function () {
            if (source) {
                source.source = null;
            }
        }));
    }
 
    return IndexEnumerator;
}(EnumeratorBase_1.default);
 
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = IndexEnumerator;
//# sourceMappingURL=IndexEnumerator.js.map