Files
discord-decomp/_bundle/Deque.js
T
2026-11-01 12:12:55 +02:00

286 lines
7.5 KiB
JavaScript

// Metro module 8 (f9).
let isArray;
const Deque = function Deque(a0) {
let _capacity;
L4: {
let r14 = a0;
if (typeof a0 !== "number") {
const isArray2 = isArray(a0);
_capacity = 16;
if (!isArray2) {
break L4;
}
r14 = a0.length;
}
const r3 = (Math.min(Math.max(16, r14), 1073741824) >>> 0) - 1;
const r24 = r3 | r3 >> 1;
const r27 = r24 | r24 >> 2;
const r30 = r27 | r27 >> 4;
const r33 = r30 | r30 >> 8;
_capacity = 1 + (r33 | r33 >> 16);
}
this._capacity = _capacity;
this._length = 0;
this._front = 0;
this._makeCapacity();
if (isArray(a0)) {
const length = a0.length;
const r6 = 0 < length;
let r44 = 0;
if (r6) {
do {
this[r44] = a0[r44];
r44 = r44 + 1;
} while (r44 < length);
}
this._length = length;
}
};
Deque.prototype.toArray = function Deque$toArray() {
const _length = this._length;
const array = new Array(_length);
const _front = this._front;
const _capacity = this._capacity;
let r0 = 0;
while (r0 < _length) {
array[r0] = this[_front + r0 & _capacity - 1];
r0 = r0 + 1;
}
return array;
};
Deque.prototype.push = function Deque$push(a0) {
const length = arguments.length;
const _length = this._length;
if (length > 1) {
const _capacity = this._capacity;
if (_length + length > _capacity) {
let r29 = 0;
const r30 = 0 < length;
let r31 = _length;
let r32 = r31;
if (r30) {
do {
this._checkCapacity(r31 + 1);
this[this._front + r31 & this._capacity - 1] = arguments[r29];
const _length2 = r31 + 1;
this._length = _length2;
r29 = r29 + 1;
r31 = _length2;
r32 = r31;
} while (r29 < length);
}
return r32;
}
let _front = this._front;
let r23 = 0;
while (r23 < length) {
this[_front + _length & _capacity - 1] = arguments[r23];
_front = _front + 1;
r23 = r23 + 1;
}
this._length = _length + length;
return _length + length;
}
let r5 = _length;
if (length !== 0) {
this._checkCapacity(_length + 1);
this[this._front + _length & this._capacity - 1] = a0;
this._length = _length + 1;
r5 = _length + 1;
}
return r5;
};
Deque.prototype.pop = function Deque$pop() {
const _length = this._length;
if (_length !== 0) {
const r10 = this._front + _length - 1 & this._capacity - 1;
const r11 = this[r10];
this[r10] = void 0;
this._length = _length - 1;
return r11;
}
};
Deque.prototype.shift = function Deque$shift() {
const _length = this._length;
if (_length !== 0) {
const _front = this._front;
const r3 = this[_front];
this[_front] = void 0;
this._front = _front + 1 & this._capacity - 1;
this._length = _length - 1;
return r3;
}
};
Deque.prototype.unshift = function Deque$unshift(a0) {
const _length = this._length;
const length = arguments.length;
if (length > 1) {
const r24 = _length + length;
const _capacity2 = this._capacity;
if (r24 > _capacity2) {
let r35 = length - 1;
let r37 = _length;
let r38 = r37;
while (0 <= r35) {
this._checkCapacity(r37 + 1);
const _capacity3 = this._capacity;
const _front4 = (this._front - 1 & _capacity3 - 1 ^ _capacity3) - _capacity3;
this[_front4] = arguments[r35];
const _length2 = r37 + 1;
this._length = _length2;
this._front = _front4;
r35 = r35 - 1;
r37 = _length2;
r38 = r37;
}
return r38;
}
let _front = this._front;
let r27 = length - 1;
let _front3 = _front;
while (0 <= r27) {
const r32 = (_front - 1 & _capacity2 - 1 ^ _capacity2) - _capacity2;
this[r32] = arguments[r27];
r27 = r27 - 1;
_front = r32;
_front3 = _front;
}
this._front = _front3;
this._length = _length + length;
return _length + length;
}
if (length === 0) {
return _length;
}
this._checkCapacity(_length + 1);
const _capacity = this._capacity;
const _front2 = (this._front - 1 & _capacity - 1 ^ _capacity) - _capacity;
this[_front2] = a0;
this._length = _length + 1;
this._front = _front2;
return _length + 1;
};
Deque.prototype.peekBack = function Deque$peekBack() {
const _length = this._length;
if (_length !== 0) {
return this[this._front + _length - 1 & this._capacity - 1];
}
};
Deque.prototype.peekFront = function Deque$peekFront() {
if (this._length !== 0) {
return this[this._front];
}
};
Deque.prototype.get = function Deque$get(a0) {
if (a0 === (a0 | 0)) {
const _length = this._length;
const r4 = a0 < 0 ? a0 + _length : a0;
if (!(r4 < 0) && !(r4 >= _length)) {
return this[this._front + r4 & this._capacity - 1];
}
}
};
Deque.prototype.isEmpty = function Deque$isEmpty() {
return this._length === 0;
};
Deque.prototype.clear = function Deque$clear() {
this._length = 0;
this._front = 0;
this._makeCapacity();
};
Deque.prototype.toString = function Deque$toString() {
return this.toArray().toString();
};
Deque.prototype.valueOf = Deque.prototype.toString;
Deque.prototype.removeFront = Deque.prototype.shift;
Deque.prototype.removeBack = Deque.prototype.pop;
Deque.prototype.insertFront = Deque.prototype.unshift;
Deque.prototype.insertBack = Deque.prototype.push;
Deque.prototype.enqueue = Deque.prototype.push;
Deque.prototype.dequeue = Deque.prototype.shift;
Deque.prototype.toJSON = Deque.prototype.toArray;
Object.defineProperty(Deque.prototype, "length", {
get: function get() {
return this._length;
},
set: function set() {
throw new RangeError("");
}
});
Deque.prototype._makeCapacity = function Deque$_makeCapacity() {
const _capacity = this._capacity;
let r0 = 0;
while (r0 < _capacity) {
this[r0] = void 0;
r0 = r0 + 1;
}
};
Deque.prototype._checkCapacity = function Deque$_checkCapacity(a0) {
let r19, _resizeTo;
if (this._capacity < a0) {
L5: {
_resizeTo = this._resizeTo;
const r2 = 1.5 * this._capacity + 16;
let r12 = r2;
if (typeof r12 !== "number") {
const isArray2 = isArray(r2);
r19 = 16;
if (!isArray2) {
break L5;
}
r12 = r2.length;
}
const r1 = (Math.min(Math.max(16, r12), 1073741824) >>> 0) - 1;
const r28 = r1 | r1 >> 1;
const r31 = r28 | r28 >> 2;
const r34 = r31 | r31 >> 4;
const r37 = r34 | r34 >> 8;
r19 = 1 + (r37 | r37 >> 16);
}
_resizeTo.call(this, r19);
}
};
Deque.prototype._resizeTo = function Deque$_resizeTo(a0) {
const _front = this._front;
const _capacity = this._capacity;
const array = new Array(_capacity);
const _length = this._length;
const r6 = 0 < _capacity;
let r0 = 0;
if (r6) {
do {
const r3 = r0 + 0;
array[r3] = this[r3];
r0 = r0 + 1;
} while (r0 < _capacity);
}
this._capacity = a0;
this._makeCapacity();
this._front = 0;
if (_front + _length <= _capacity) {
const r34 = 0 < _length;
let r35 = 0;
if (r34) {
do {
this[r35 + 0] = array[r35 + _front];
r35 = r35 + 1;
} while (r35 < _length);
}
} else {
const r5 = _length - (_front + _length & _capacity - 1);
let r26 = 0;
while (r26 < r5) {
this[r26 + 0] = array[r26 + _front];
r26 = r26 + 1;
}
const r30 = _length - r5;
let r31 = 0;
while (r31 < r30) {
this[r31 + r5] = array[r31 + 0];
r31 = r31 + 1;
}
}
};
isArray = Array.isArray;
module.exports = Deque;