123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121 |
- "use strict";
- var __importDefault = (this && this.__importDefault) || function (mod) {
- return (mod && mod.__esModule) ? mod : { "default": mod };
- };
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.generate = exports.compile = void 0;
- var boolbase_1 = __importDefault(require("boolbase"));
- function compile(parsed) {
- var a = parsed[0];
-
- var b = parsed[1] - 1;
-
- if (b < 0 && a <= 0)
- return boolbase_1.default.falseFunc;
-
- if (a === -1)
- return function (index) { return index <= b; };
- if (a === 0)
- return function (index) { return index === b; };
-
- if (a === 1)
- return b < 0 ? boolbase_1.default.trueFunc : function (index) { return index >= b; };
-
- var absA = Math.abs(a);
-
- var bMod = ((b % absA) + absA) % absA;
- return a > 1
- ? function (index) { return index >= b && index % absA === bMod; }
- : function (index) { return index <= b && index % absA === bMod; };
- }
- exports.compile = compile;
- function generate(parsed) {
- var a = parsed[0];
-
- var b = parsed[1] - 1;
- var n = 0;
-
- if (a < 0) {
- var aPos_1 = -a;
-
- var minValue_1 = ((b % aPos_1) + aPos_1) % aPos_1;
- return function () {
- var val = minValue_1 + aPos_1 * n++;
- return val > b ? null : val;
- };
- }
- if (a === 0)
- return b < 0
- ?
- function () { return null; }
- :
- function () { return (n++ === 0 ? b : null); };
- if (b < 0) {
- b += a * Math.ceil(-b / a);
- }
- return function () { return a * n++ + b; };
- }
- exports.generate = generate;
|