An append-only memory allocator with the same interface as malloc, useful for implementing append only logs. Has no
free() but does not enforce write-once.
It lets you allocate a large, contiguous slab of memory up front and then
alloc() within that buffer.
It is mostly useful in conjunction with things like mmap.js.
It's developed using design by contract, so you might find the library's own code style a bit unusual, but it doesn't affect usage or performance.
Install via npm.
;const heap = 1024 * 1024;const allocator = heap; // heap could also be an ArrayBufferconsole;let firstAddress = 0;let lastAddress = 0;for let i = 0; i < 100; i++const address = allocator;if firstAddress === 0firstAddress = address;if lastAddress !== 0// do something with the addressheap;let address = firstAddress;for let i = 0; i < 100; i++console;address = heap;