All files main.js

100% Statements 115/115
100% Branches 100/100
100% Functions 33/33
100% Lines 107/107

Press n or j to go to the next uncovered block, b, p or k for the previous block.

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 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200  1x 1x   31x 31x 31x 260x 260x 10x   250x 44x 44x     206x     31x 31x     1x 1x 7x   1x 15x   1x 7x     1x   1x 1x 7x         1x 15x 15x   1x 7x     1x   2x 2x 14x         2x 30x   2x 14x     1x   2x 2x 14x           2x 30x 30x   2x 14x     1x   29x 2x   27x   1x   56540x           1x   60466x           1x   5x 11x 6x   5x     1x   60x 271x 38x   233x     1x   49x 106x   31x 31x 62x 62x 146x   62x   31x   1x   2x 33x 44x 44x 24x     9x     1x 244x   33x 33x 39x 8x   31x 2x   29x 2x   27x 10x   17x     1x   15x   1x   15x   1x   16x   12x     8x     8x     8x   3x   1x  
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const UNDEF = {};
function split(toSplit, by) {
    const result = [];
    let buffer = [];
    for (let i = 0, j = toSplit.length; i < j; ++i) {
        const c = toSplit[i];
        if (c === "\\") {
            buffer.push(toSplit[++i]);
        }
        else if (c === by) {
            result.push(buffer.join(""));
            buffer = [];
        }
        else {
            buffer.push(c);
        }
    }
    result.push(buffer.join(""));
    return result;
}
function sort(items, comparator = natural) {
    const tmp = items;
    for (let i = 0, j = items.length; i < j; ++i) {
        tmp[i] = tmp[i] !== undefined ? tmp[i] : UNDEF;
    }
    tmp.sort((lhs, rhs) => {
        return comparator(lhs !== UNDEF ? lhs : undefined, rhs !== UNDEF ? rhs : undefined);
    });
    for (let i = 0, j = tmp.length; i < j; ++i) {
        tmp[i] = tmp[i] !== UNDEF ? tmp[i] : undefined;
    }
}
exports.sort = sort;
function sortStable(items, comparator = natural) {
    const tmp = items;
    for (let i = 0, j = items.length; i < j; ++i) {
        tmp[i] = {
            i,
            v: tmp[i],
        };
    }
    tmp.sort((lhs, rhs) => {
        const result = comparator(lhs.v, rhs.v);
        return result !== 0 ? result : lhs.i - rhs.i;
    });
    for (let i = 0, j = tmp.length; i < j; ++i) {
        tmp[i] = tmp[i].v;
    }
}
exports.sortStable = sortStable;
function sortBy(items, keyExtractor, comparator = natural) {
    const tmp = items;
    for (let i = 0, j = items.length; i < j; ++i) {
        tmp[i] = {
            k: keyExtractor(tmp[i]),
            v: tmp[i],
        };
    }
    tmp.sort((lhs, rhs) => {
        return comparator(lhs.k, rhs.k);
    });
    for (let i = 0, j = tmp.length; i < j; ++i) {
        tmp[i] = tmp[i].v;
    }
}
exports.sortBy = sortBy;
function sortStableBy(items, keyExtractor, comparator = natural) {
    const tmp = items;
    for (let i = 0, j = items.length; i < j; ++i) {
        tmp[i] = {
            i,
            k: keyExtractor(tmp[i]),
            v: tmp[i],
        };
    }
    tmp.sort((lhs, rhs) => {
        const result = comparator(lhs.k, rhs.k);
        return result !== 0 ? result : lhs.i - rhs.i;
    });
    for (let i = 0, j = tmp.length; i < j; ++i) {
        tmp[i] = tmp[i].v;
    }
}
exports.sortStableBy = sortStableBy;
function comparable(lhs, rhs) {
    if (lhs === undefined) {
        return rhs === undefined ? 0 : -1;
    }
    return rhs === undefined ? 1 : lhs.compareTo(rhs);
}
exports.comparable = comparable;
function natural(lhs, rhs) {
    return lhs !== undefined ?
        (rhs !== undefined ?
            (lhs < rhs ? -1 : lhs > rhs ? 1 : 0) :
            1) :
        (rhs !== undefined ? -1 : 0);
}
exports.natural = natural;
function inverse(lhs, rhs) {
    return lhs !== undefined ?
        (rhs !== undefined ?
            (lhs < rhs ? 1 : lhs > rhs ? -1 : 0) :
            1) :
        (rhs !== undefined ? -1 : 0);
}
exports.inverse = inverse;
function invert(comparator) {
    return (lhs, rhs) => {
        if (lhs === undefined || rhs === undefined) {
            return comparator(lhs, rhs);
        }
        return -comparator(lhs, rhs);
    };
}
exports.invert = invert;
function byKey(keyExtractor, keyComparator = natural) {
    return (lhs, rhs) => {
        if (lhs === undefined) {
            return rhs === undefined ? 0 : -1;
        }
        return rhs === undefined ? 1 : keyComparator(keyExtractor(lhs), keyExtractor(rhs));
    };
}
exports.byKey = byKey;
function byProp(keySpecifier, comparator) {
    if (keySpecifier.indexOf(".") < 0) {
        return byKey(x => x[keySpecifier], comparator);
    }
    const fields = split(keySpecifier, ".");
    const keyExtractor = (object) => {
        let value = object;
        for (let i = 0, j = fields.length; i < j && value !== undefined; ++i) {
            value = value[fields[i]];
        }
        return value;
    };
    return byKey(keyExtractor, comparator);
}
exports.byProp = byProp;
function combine(...comparators) {
    return (lhs, rhs) => {
        for (let i = 0, j = comparators.length; i < j; ++i) {
            const result = comparators[i](lhs, rhs);
            if (result !== 0) {
                return result;
            }
        }
        return 0;
    };
}
exports.combine = combine;
exports.ignoreCase = byKey(item => item.toLowerCase());
function byThreshold(threshold = 1E-12) {
    threshold = Math.max(0, threshold);
    return (lhs, rhs) => {
        if (lhs === rhs) {
            return 0;
        }
        if (lhs === undefined) {
            return -1;
        }
        if (rhs === undefined) {
            return 1;
        }
        if (lhs < rhs) {
            return rhs - lhs < threshold ? 0 : -1;
        }
        return isNaN(rhs) ? (isNaN(lhs) ? 0 : -1) : lhs - rhs < threshold ? 0 : 1;
    };
}
exports.byThreshold = byThreshold;
function equals(comparator = natural) {
    return (lhs, rhs) => comparator(lhs, rhs) === 0;
}
exports.equals = equals;
function equalTo(item, test = natural) {
    return (x) => test(item, x) === 0;
}
exports.equalTo = equalTo;
function within(lower, upper, { comparator = natural, mode = "[]", } = {}) {
    switch (mode) {
        case "[]":
            return item => comparator(lower, item) <= 0 && comparator(item, upper) <= 0;
        case "()":
        case "][":
            return item => comparator(lower, item) < 0 && comparator(item, upper) < 0;
        case "[)":
        case "[[":
            return item => comparator(lower, item) <= 0 && comparator(item, upper) < 0;
        case "(]":
        case "]]":
            return item => comparator(lower, item) < 0 && comparator(item, upper) <= 0;
    }
    throw new Error(`invalid mode ${mode}, must be one of [] () [) (]`);
}
exports.within = within;