Skip to content

Instantly share code, notes, and snippets.

View jhmaster2000's full-sized avatar
๐Ÿ‘๏ธโ€๐Ÿ—จ๏ธ

jhmaster jhmaster2000

๐Ÿ‘๏ธโ€๐Ÿ—จ๏ธ
View GitHub Profile
@jhmaster2000
jhmaster2000 / irrationalarray.mts
Created October 6, 2023 02:53
Array with irrational number indexes, PoC
// Because JS isn't cursed enough :)
import util from 'node:util';
class IrrationalArray extends Array {
constructor(...args: any[]) {
super(...args);
const indexes = Object.keys(this).filter(key => !Number.isNaN(Number(key))).map(key => Number(key)).sort((a, b) => a - b);
for (const index of indexes) this._data.set(index, this[index]);
super.length = 0;
return new Proxy(this, {