all files / TypeScript.NET/source/System/Collections/Sorting/ SortContext.js

78.95% Statements 30/38
50% Branches 10/20
88.89% Functions 8/9
84.38% Lines 27/32
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                    17× 17× 17× 17× 17×           16× 16×   66× 82× 16×   34× 34× 34×   34×        
/*!
 * @author electricessence / https://github.com/electricessence/
 * Licensing: MIT https://github.com/electricessence/TypeScript.NET/blob/master/LICENSE.md
 */
(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", "../../Compare"], factory);
    }
})(function (require, exports) {
    "use strict";
    var Values = require("../../Compare");
    var SortContext = (function () {
        function SortContext(_next, _comparer, _order) {
            Iif (_comparer === void 0) { _comparer = Values.compare; }
            Iif (_order === void 0) { _order = 1; }
            this._next = _next;
            this._comparer = _comparer;
            this._order = _order;
        }
        Object.defineProperty(SortContext.prototype, "order", {
            get: function () { return this._order; },
            enumerable: true,
            configurable: true
        });
        SortContext.prototype.generateSortedIndexes = function (source) {
            var _this = this;
            Iif (source == null)
                return [];
            var result = source.map(function (s, i) { return i; });
            result.sort(function (a, b) { return _this.compare(source[a], source[b]); });
            return result;
        };
        SortContext.prototype.compare = function (a, b) {
            var _ = this;
            var d = _._comparer(a, b);
            Iif (d == 0 && _._next)
                return _._next.compare(a, b);
            return _._order * d;
        };
        return SortContext;
    }());
    exports.SortContext = SortContext;
    Object.defineProperty(exports, "__esModule", { value: true });
    exports.default = SortContext;
});
//# sourceMappingURL=SortContext.js.map