mirror of
https://github.com/swc-project/swc.git
synced 2024-12-21 12:41:54 +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");
|