@e9x/ipi
Version:
A free library/cli tool to get IP information.
34 lines (33 loc) • 1.4 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const eq = ([LOWER, UPPER], [COMPARE_LOWER, COMPARE_UPPER], math) => `(${math.eq(LOWER, COMPARE_LOWER)} AND ${math.eq(UPPER, COMPARE_UPPER)})`;
const gt = ([LOWER, UPPER], [COMPARE_LOWER, COMPARE_UPPER], math) => `iif(${math.eq(UPPER, COMPARE_UPPER)}, ${math.gt(LOWER, COMPARE_LOWER)}, ${math.gt(UPPER, COMPARE_UPPER)})`;
const lt = ([LOWER, UPPER], [COMPARE_LOWER, COMPARE_UPPER], math) => `iif(${math.eq(UPPER, COMPARE_UPPER)}, ${math.lt(LOWER, COMPARE_LOWER)}, ${math.lt(UPPER, COMPARE_UPPER)})`;
const gteq = (a, b, math) => `(${gt(a, b, math)} OR ${eq(a, b, math)})`;
const lteq = (a, b, math) => `(${lt(a, b, math)} OR ${eq(a, b, math)})`;
const math32 = {
eq: (a, b) => `(${a} == ${b})`,
lt: (a, b) => `(${a} < ${b})`,
gt: (a, b) => `(${a} > ${b})`,
};
const math64 = {
eq: (a, b) => eq(a, b, math32),
lt: (a, b) => lt(a, b, math32),
gt: (a, b) => gt(a, b, math32),
};
const var_range_start = [
["range_start4", "range_start3"],
["range_start2", "range_start1"],
];
const var_range_end = [
["range_end4", "range_end3"],
["range_end2", "range_end1"],
];
const bind_var_ip = [
[":ip4", ":ip3"],
[":ip2", ":ip1"],
];
const conditionIP = lteq(var_range_start, bind_var_ip, math64) +
" AND " +
gteq(var_range_end, bind_var_ip, math64);
exports.default = conditionIP;