aboutsummaryrefslogtreecommitdiff
path: root/examples/mmap/1.js
blob: 1c4f2c969d16a72846f9acdcc293e5dab2356949 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
const map = Bun.mmap("./mmap.txt", { shared: true });
const utf8deocder = new TextDecoder("utf-8");

let old = new TextEncoder().encode("12345");

setInterval(() => {
  old = old.sort((a, b) => (Math.random() > 0.5 ? -1 : 1));
  console.log(`changing mmap to ~> ${utf8deocder.decode(old)}`);

  map.set(old);
}, 4);