@k3000/store 1.1.2 → 1.1.5

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/architect.mjs CHANGED
@@ -7,6 +7,7 @@ import {createCipheriv, createDecipheriv, createHash, scryptSync} from "node:cry
7
7
  *
8
8
  * @param {Array} array
9
9
  * @param {Function | String} predicate
10
+ * @param {Function} map
10
11
  * @return {Array}
11
12
  */
12
13
  Array.prototype.eachFlat = function (array, predicate, map) {
@@ -48,6 +49,7 @@ Array.prototype.eachFlat = function (array, predicate, map) {
48
49
  *
49
50
  * @param {Array} array
50
51
  * @param {Function | String} predicate
52
+ * @param {Function} map
51
53
  * @return {Array}
52
54
  */
53
55
  Array.prototype.filterFlat = function (array, predicate, map) {
@@ -75,6 +77,7 @@ Array.prototype.filterFlat = function (array, predicate, map) {
75
77
  }
76
78
  }
77
79
 
80
+ const MaxSize = 99999
78
81
  /**
79
82
  * 时间筛选的最大值
80
83
  * @type {number}
@@ -617,7 +620,7 @@ export class Entities extends Array {
617
620
  /**
618
621
  * 分页
619
622
  * @param {Function} predicate
620
- * @param index
623
+ * @param page
621
624
  * @param size
622
625
  * @param params
623
626
  * @return {*[]|*|*[]}
@@ -1104,11 +1107,14 @@ export class Storage {
1104
1107
  console.error(e)
1105
1108
  }
1106
1109
 
1107
- this.#values.set(position, {
1108
- value,
1109
- expired: false,
1110
- needsSave: true,
1111
- })
1110
+ if (this.#values.size < MaxSize) {
1111
+
1112
+ this.#values.set(position, {
1113
+ value,
1114
+ expired: false,
1115
+ needsSave: false,
1116
+ })
1117
+ }
1112
1118
 
1113
1119
  return value
1114
1120
  }
@@ -1149,11 +1155,14 @@ export class Storage {
1149
1155
 
1150
1156
  const needsSave = !val.equals(value)
1151
1157
 
1152
- this.#values.set(position, {
1153
- value,
1154
- expired: true,
1155
- needsSave,
1156
- })
1158
+ if (this.#values.size < MaxSize) {
1159
+
1160
+ this.#values.set(position, {
1161
+ value,
1162
+ expired: true,
1163
+ needsSave,
1164
+ })
1165
+ }
1157
1166
 
1158
1167
  return needsSave
1159
1168
  }
@@ -1451,7 +1460,7 @@ export const bigUint32BEToBuffer = value => {
1451
1460
 
1452
1461
  const buffer = Buffer.alloc(TypeLen.bigUint)
1453
1462
 
1454
- buffer.writeBigUint64BE(value, 0)
1463
+ buffer.writeBigUint64BE(BigInt(value || 0), 0)
1455
1464
 
1456
1465
  return buffer
1457
1466
  }
@@ -1460,7 +1469,7 @@ export const bigint32BEToBuffer = value => {
1460
1469
 
1461
1470
  const buffer = Buffer.alloc(TypeLen.bigint)
1462
1471
 
1463
- buffer.writeBigInt64BE(value, 0)
1472
+ buffer.writeBigInt64BE(BigInt(value || 0), 0)
1464
1473
 
1465
1474
  return buffer
1466
1475
  }
package/generator.mjs CHANGED
@@ -589,6 +589,10 @@ function appendSet(name, set, remark = '') {
589
589
  if (value.index) {
590
590
 
591
591
  value.index = []
592
+
593
+ } else if (Reflect.has(value, 'index')) {
594
+
595
+ delete value.index
592
596
  }
593
597
  }
594
598
 
@@ -636,6 +640,10 @@ function updateCol(name, set) {
636
640
  if (value.index) {
637
641
 
638
642
  value.index = []
643
+
644
+ } else if (Reflect.has(value, 'index')) {
645
+
646
+ delete value.index
639
647
  }
640
648
  }
641
649
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@k3000/store",
3
- "version": "1.1.2",
3
+ "version": "1.1.5",
4
4
  "description": "storage",
5
5
  "main": "generator.mjs",
6
6
  "scripts": {
package/test/1/data CHANGED
Binary file
package/test/1/index CHANGED
Binary file
package/test/2/data CHANGED
Binary file
package/test/2/index CHANGED
Binary file
package/test/index.mjs CHANGED
@@ -1,15 +1,15 @@
1
1
 
2
2
  const index = import.meta.url.indexOf('?')
3
3
 
4
- export const modules = await import(`./7/index.mjs${index > -1 ? import.meta.url.substring(index) : ''}`)
4
+ export const modules = await import(`./2/index.mjs${index > -1 ? import.meta.url.substring(index) : ''}`)
5
5
 
6
6
  export const close = modules.close
7
7
  export const remark = modules.remark
8
- export const version = 7
8
+ export const version = 2
9
9
  export const getStruct = modules.getStruct
10
10
 
11
11
  /**
12
- * @type {import('./7/type').Storage}
12
+ * @type {import('./2/type').Storage}
13
13
  */
14
14
  export const storage = modules.default
15
15