# all files / TypeScript.NET/source/System/Collections/Enumeration/ IndexEnumerator.js

88.89% Statements 48/54
80.39% Branches 41/51
100% Functions 9/9
93.88% Lines 46/49

    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

    1×
    1×
    1×
    1×

    1×
    1×
    1×

    1×
    1×
    1×
    1×
    311×
    311×
    308×
    308×
    306×
    306×
    1×
    305×

    305×
    1×
    304×
    304×
    291×
    13×
    1×
    303×
    303×
    303×
    1×
    302×
    1×
    302×

    1402×
    1402×
    25×
    1377×
    1377×
    1377×

    310×
    307×

    311×

    1×

    1×
    1×
    1×

     /*!
     * @author electricessence / https://github.com/electricessence/
     * Licensing: MIT https://github.com/electricessence/TypeScript.NET/blob/master/LICENSE.md
     */
    var __extends = (this && this.__extends) || function (d, b) {
        for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
    (function (factory) {
        Eif (typeof module === 'object' && typeof module.exports === 'object') {
            var v = factory(require, exports); Iif (v !== undefined) module.exports = v;
        }
        else if (typeof define === 'function' && define.amd) {
            define(["require", "exports", "./EnumeratorBase"], factory);
        }
    })(function (require, exports) {
        "use strict";
        var EnumeratorBase_1 = require("./EnumeratorBase");
        var IndexEnumerator = (function (_super) {
            __extends(IndexEnumerator, _super);
            function IndexEnumerator(sourceFactory) {
                var source;
                _super.call(this, function () {
                    source = sourceFactory();
                    if (source && source.source) {
                        var len = source.length;
                        if (len < 0)
                            throw new Error("length must be zero or greater");
                        Iif (!isFinite(len))
                            throw new Error("length must finite number");
                        if (len && source.step === 0)
                            throw new Error("Invalid IndexEnumerator step value (0).");
                        var pointer = source.pointer;
                        if (!pointer)
                            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)
                            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;
                    }
                });
                this._isEndless = false;
            }
            return IndexEnumerator;
        }(EnumeratorBase_1.EnumeratorBase));
        exports.IndexEnumerator = IndexEnumerator;
        Object.defineProperty(exports, "__esModule", { value: true });
        exports.default = IndexEnumerator;
    });
    //# sourceMappingURL=IndexEnumerator.js.map