bumparena 0.9.0 → 0.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -2
- package/interface.d.ts +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -53,12 +53,14 @@ yarn add bumparena
|
|
|
53
53
|
|
|
54
54
|
## Quick Start
|
|
55
55
|
|
|
56
|
+
for more Advanced Usages go to [test/example.ts](https://github.com/eugen252009/BumpArena/blob/main/test/example.ts)
|
|
57
|
+
|
|
56
58
|
```ts
|
|
57
59
|
import { Arena } from "bumparena";
|
|
58
60
|
import fs from "node:fs";
|
|
59
61
|
|
|
60
62
|
// 1. Initialize (e.g., 1GB Arena)
|
|
61
|
-
const arena = new Arena({
|
|
63
|
+
const arena = new Arena({ initialSize: 1024 * 1024 * 1024 });
|
|
62
64
|
|
|
63
65
|
// 2. Map data instantly (Zero-Copy)
|
|
64
66
|
const data = new Uint8Array([10, 20, 30, 40]);
|
|
@@ -74,7 +76,7 @@ fs.writeFileSync("database.bin", arena.getBuffer());
|
|
|
74
76
|
// 5. Reload (Zero Parsing Time)
|
|
75
77
|
// Simply load the bytes back into a new Arena buffer
|
|
76
78
|
const savedData = fs.readFileSync("database.bin");
|
|
77
|
-
const restoredArena = new Arena({
|
|
79
|
+
const restoredArena = new Arena({ initialSize: savedData.byteLength });
|
|
78
80
|
restoredArena.putBytes(savedData); // Structure is restored instantly
|
|
79
81
|
|
|
80
82
|
//Clear your Arena, if you want a restart
|
package/interface.d.ts
CHANGED