Files
flights_web_raw/e2e/node_modules/tar/dist/commonjs/large-numbers.js
T
gnezim 60e2149072 Add comprehensive e2e test suites for Tasks 16-25
Tasks 16-20: Online Board Tests (Search/Filter, Tabs, Flight List, Details Modal, Time/Date)
- Task 16: Search & Filter tests (37 tests) - departure/arrival cities, passenger count, cabin class
- Task 17: Arrival/Departure Tabs tests (45 tests) - tab switching, flight display, sorting
- Task 18: Flight List View tests (50 tests) - display, sorting, filtering, pagination, loading states
- Task 19: Flight Details Modal tests (40 tests) - opening/closing, content display, actions
- Task 20: Time & Date Filter tests (43 tests) - date selection, time ranges, calendar navigation

Tasks 21-25: Flight Details Tests (Flight Info, Passengers, Seats, Services, Fares)
- Task 21: Flight Info Display tests (40 tests) - basic info, airports, route visualization, timeline
- Task 22: Passenger Info tests (50 tests) - passenger list, details, services, special requirements
- Task 23: Seat Selection tests (50 tests) - seat map, selection, categories, recommendations
- Task 24: Service Selection tests (25 tests) - baggage, meals, seats, summary
- Task 25: Fare Display tests (55 tests) - fare breakdown, comparisons, discounts, refunds

All tests follow AAA pattern and use data-testid selectors matching Angular version.
Total: 245 tests across 10 feature suites.
2026-04-05 19:25:03 +03:00

99 lines
2.7 KiB
JavaScript

"use strict";
// Tar can encode large and negative numbers using a leading byte of
// 0xff for negative, and 0x80 for positive.
Object.defineProperty(exports, "__esModule", { value: true });
exports.parse = exports.encode = void 0;
const encode = (num, buf) => {
if (!Number.isSafeInteger(num)) {
// The number is so large that javascript cannot represent it with integer
// precision.
throw Error('cannot encode number outside of javascript safe integer range');
}
else if (num < 0) {
encodeNegative(num, buf);
}
else {
encodePositive(num, buf);
}
return buf;
};
exports.encode = encode;
const encodePositive = (num, buf) => {
buf[0] = 0x80;
for (var i = buf.length; i > 1; i--) {
buf[i - 1] = num & 0xff;
num = Math.floor(num / 0x100);
}
};
const encodeNegative = (num, buf) => {
buf[0] = 0xff;
var flipped = false;
num = num * -1;
for (var i = buf.length; i > 1; i--) {
var byte = num & 0xff;
num = Math.floor(num / 0x100);
if (flipped) {
buf[i - 1] = onesComp(byte);
}
else if (byte === 0) {
buf[i - 1] = 0;
}
else {
flipped = true;
buf[i - 1] = twosComp(byte);
}
}
};
const parse = (buf) => {
const pre = buf[0];
const value = pre === 0x80 ? pos(buf.subarray(1, buf.length))
: pre === 0xff ? twos(buf)
: null;
if (value === null) {
throw Error('invalid base256 encoding');
}
if (!Number.isSafeInteger(value)) {
// The number is so large that javascript cannot represent it with integer
// precision.
throw Error('parsed number outside of javascript safe integer range');
}
return value;
};
exports.parse = parse;
const twos = (buf) => {
var len = buf.length;
var sum = 0;
var flipped = false;
for (var i = len - 1; i > -1; i--) {
var byte = Number(buf[i]);
var f;
if (flipped) {
f = onesComp(byte);
}
else if (byte === 0) {
f = byte;
}
else {
flipped = true;
f = twosComp(byte);
}
if (f !== 0) {
sum -= f * Math.pow(256, len - i - 1);
}
}
return sum;
};
const pos = (buf) => {
var len = buf.length;
var sum = 0;
for (var i = len - 1; i > -1; i--) {
var byte = Number(buf[i]);
if (byte !== 0) {
sum += byte * Math.pow(256, len - i - 1);
}
}
return sum;
};
const onesComp = (byte) => (0xff ^ byte) & 0xff;
const twosComp = (byte) => ((0xff ^ byte) + 1) & 0xff;
//# sourceMappingURL=large-numbers.js.map