mirror of
https://github.com/swc-project/swc.git
synced 2024-12-24 06:05:02 +03:00
12 lines
324 B
TypeScript
12 lines
324 B
TypeScript
const heap = new Array(32).fill(undefined);
|
|
heap.push(undefined, null, true, false);
|
|
let heap_next = heap.length;
|
|
function addHeapObject(obj) {
|
|
if (heap_next === heap.length) heap.push(heap.length + 1);
|
|
const idx = heap_next;
|
|
heap_next = heap[idx];
|
|
heap[idx] = obj;
|
|
return idx;
|
|
}
|
|
addHeapObject("hello");
|