@wxn0brp/db-storage-bin 0.0.4 → 0.0.6

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/CHANGELOG.md CHANGED
@@ -2,6 +2,15 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ### [0.0.6](https://github.com/wxn0brp/ValtheraDB-storage-bin/compare/v0.0.5...v0.0.6) (2025-09-18)
6
+
7
+ ### [0.0.5](https://github.com/wxn0brp/ValtheraDB-storage-bin/compare/v0.0.4...v0.0.5) (2025-09-04)
8
+
9
+
10
+ ### Bug Fixes
11
+
12
+ * crc and new crc mode ([cc79715](https://github.com/wxn0brp/ValtheraDB-storage-bin/commit/cc7971591dbcd39fd5b9371644d2c3e9997f0dbc))
13
+
5
14
  ### [0.0.4](https://github.com/wxn0brp/ValtheraDB-storage-bin/compare/v0.0.3...v0.0.4) (2025-09-04)
6
15
 
7
16
 
package/dist/bin/data.js CHANGED
@@ -71,7 +71,8 @@ export async function writeLogic(cmp, collection, data) {
71
71
  await _log(2, "Capacity exceeded");
72
72
  }
73
73
  else {
74
- if (cmp.options.crc) {
74
+ const crc = cmp.options.crc;
75
+ if (crc === 3 || crc === 4) {
75
76
  const { computedCrc } = await getFileCrc(fd);
76
77
  const crcBuf = Buffer.alloc(16);
77
78
  crcBuf.writeUInt32LE(computedCrc);
package/dist/bin/head.js CHANGED
@@ -51,7 +51,7 @@ export async function openFile(cmp) {
51
51
  }
52
52
  if (!validCrc) {
53
53
  await _log(0, "err", "Invalid CRC");
54
- if (options.crc === 2)
54
+ if (options.crc === 2 || options.crc === 4)
55
55
  throw new Error("Invalid CRC");
56
56
  }
57
57
  }
@@ -11,6 +11,8 @@ export interface Options {
11
11
  * 0 - crc off
12
12
  * 1 - warn if error
13
13
  * 2 - throw if error
14
+ * 3 - 1 & save always on edit
15
+ * 4 - 2 & save always on edit
14
16
  */
15
17
  crc: number;
16
18
  overwriteRemovedCollection: boolean;
@@ -34,6 +36,7 @@ export declare class BinManager {
34
36
  constructor(path: string, options?: Partial<Options>);
35
37
  open(): Promise<void>;
36
38
  close(): Promise<void>;
39
+ [Symbol.asyncDispose](): Promise<void>;
37
40
  write<T = object[]>(collection: string, data: T): Promise<void>;
38
41
  read(collection: string): Promise<any>;
39
42
  optimize(): Promise<void>;
package/dist/bin/index.js CHANGED
@@ -64,6 +64,9 @@ export class BinManager {
64
64
  this.fd = null;
65
65
  }
66
66
  }
67
+ [Symbol.asyncDispose]() {
68
+ return this.close();
69
+ }
67
70
  async write(collection, data) {
68
71
  if (!this.fd)
69
72
  throw new Error("File not open");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wxn0brp/db-storage-bin",
3
- "version": "0.0.4",
3
+ "version": "0.0.6",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "author": "wxn0brP",
@@ -13,7 +13,7 @@
13
13
  "homepage": "https://github.com/wxn0brp/ValtheraDB-storage-bin",
14
14
  "devDependencies": {
15
15
  "@types/node": "^24.3.0",
16
- "@wxn0brp/db-core": "^0.1.5",
16
+ "@wxn0brp/db-core": "^0.2.0",
17
17
  "tsc-alias": "^1.8.10",
18
18
  "typescript": "^5.9.2"
19
19
  },
@@ -21,7 +21,7 @@
21
21
  "@msgpack/msgpack": "^3.1.2"
22
22
  },
23
23
  "peerDependencies": {
24
- "@wxn0brp/db-core": ">=0.1.5"
24
+ "@wxn0brp/db-core": ">=0.2.0"
25
25
  },
26
26
  "exports": {
27
27
  ".": {
package/src/bin/data.ts CHANGED
@@ -80,7 +80,8 @@ export async function writeLogic(cmp: BinManager, collection: string, data: any)
80
80
  await saveHeaderAndPayload(cmp);
81
81
  await _log(2, "Capacity exceeded");
82
82
  } else {
83
- if (cmp.options.crc) {
83
+ const crc = cmp.options.crc;
84
+ if (crc === 3 || crc === 4) {
84
85
  const { computedCrc } = await getFileCrc(fd);
85
86
  const crcBuf = Buffer.alloc(16);
86
87
  crcBuf.writeUInt32LE(computedCrc);
package/src/bin/head.ts CHANGED
@@ -74,7 +74,7 @@ export async function openFile(cmp: BinManager) {
74
74
  }
75
75
  if (!validCrc) {
76
76
  await _log(0, "err", "Invalid CRC");
77
- if (options.crc === 2)
77
+ if (options.crc === 2 || options.crc === 4)
78
78
  throw new Error("Invalid CRC");
79
79
  }
80
80
  }
package/src/bin/index.ts CHANGED
@@ -29,6 +29,8 @@ export interface Options {
29
29
  * 0 - crc off
30
30
  * 1 - warn if error
31
31
  * 2 - throw if error
32
+ * 3 - 1 & save always on edit
33
+ * 4 - 2 & save always on edit
32
34
  */
33
35
  crc: number;
34
36
  overwriteRemovedCollection: boolean;
@@ -87,6 +89,10 @@ export class BinManager {
87
89
  }
88
90
  }
89
91
 
92
+ [Symbol.asyncDispose]() {
93
+ return this.close();
94
+ }
95
+
90
96
  async write<T = object[]>(collection: string, data: T) {
91
97
  if (!this.fd) throw new Error("File not open");
92
98
  await writeLogic(this, collection, data);