mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-10-23 06:10:02 +08:00
Represent ordinary JavaScript arrays with hole, value, and explicit-undefined states; add sparse side storage and carry missing values through the frontend, native backends, runtime, and Node-facing consumers.
12 lines
398 B
TypeScript
12 lines
398 B
TypeScript
// Searches must jump over a billion-index hole run instead of visiting every
|
|
// absent position. The completion itself is the regression signal.
|
|
const high = 1_000_000_000;
|
|
const sparse: number[] = [];
|
|
sparse[high] = 7;
|
|
|
|
console.log(sparse.length);
|
|
console.log(sparse.indexOf(sparse[high]), sparse.includes(sparse[high]));
|
|
|
|
const missing = sparse[high - 1];
|
|
console.log(sparse.includes(missing));
|