diff options
Diffstat (limited to 'examples/mmap/1.js')
-rw-r--r-- | examples/mmap/1.js | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/examples/mmap/1.js b/examples/mmap/1.js new file mode 100644 index 000000000..1c4f2c969 --- /dev/null +++ b/examples/mmap/1.js @@ -0,0 +1,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); |