const format = new Intl.NumberFormat([], {
minimumIntegerDigits: 10,
useGrouping: false,
}).format;
const toValueIndexTuple = (value, index) => [value, index];
const byValueAsc = ([a], [b]) => a - b;
function shuffledKeys(entries) {
const values = new Uint32Array(entries.length);
crypto.getRandomValues(values);
const pickKey = ([, index]) => entries[index][0];
return Array.from(values, toValueIndexTuple).sort(byValueAsc).map(pickKey);
}
const toKeyEntry = (_value, index) => [
'key' + format(SIZE - index - 1),
format(index),
];
const SIZE = 10;
const ACCESS_PASSES = 1;
const entries = Array.from({ length: SIZE }, toKeyEntry);
const accessPattern = Array.from({ length: ACCESS_PASSES }, (_v) =>
shuffledKeys(entries)
).flat();
const map = new Map(entries);
const objectMap = Object.fromEntries(entries);