@k3000/store 1.0.2 → 1.1.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/architect.mjs CHANGED
@@ -1,4 +1,5 @@
1
- import {dirname, resolve} from "node:path"
1
+ import {dirname} from "node:path"
2
+ import {fileURLToPath} from "node:url"
2
3
  import {openSync, closeSync, readFileSync, writeFileSync, readSync, writeSync, unlinkSync} from "node:fs"
3
4
  import {createCipheriv, createDecipheriv, createHash, scryptSync} from "node:crypto"
4
5
 
@@ -820,15 +821,13 @@ export class Storage {
820
821
 
821
822
  constructor(url, password, newPwd) {
822
823
 
823
- url = decodeURI(url)
824
+ let dir = url.startsWith('file:///') ? dirname(fileURLToPath(url)) : url
824
825
 
825
- let dir = url.endsWith('/') ? url : dirname(url) + '/'
826
+ dir = dir.replace(/\\/g, '/')
826
827
 
827
- const root = resolve('/')
828
+ if (!dir.endsWith('/')) {
828
829
 
829
- if (dir.startsWith('file:///')) {
830
-
831
- dir = root.length > 1 ? dir.substring(7 + root.length) : dir.substring(7)
830
+ dir += '/'
832
831
  }
833
832
 
834
833
  this.#fd_data = openSync(dir + 'data', 'r+')
package/generator.mjs CHANGED
@@ -761,6 +761,17 @@ const commentRemark = (remark = '') => remark.replace(/\n/g, '\n\t * ')
761
761
 
762
762
  function submit() {
763
763
 
764
+ for (const name of this.updateSet.values()) {
765
+
766
+ this.curr.record.idle[name] = []
767
+ this.curr.record.record[name] = []
768
+
769
+ for (const key of Object.keys(this.curr.record.index[name])) {
770
+
771
+ this.curr.record.index[name][key] = []
772
+ }
773
+ }
774
+
764
775
  this.curr.updateStruct(this.curr.struct)
765
776
  this.curr.updateRecord(this.curr.record)
766
777
 
@@ -803,10 +814,6 @@ export default storage
803
814
 
804
815
  for (const name of this.updateSet.values()) {
805
816
 
806
- curr[name].remove(...curr[name])
807
-
808
- this.curr.record.idle[name] = []
809
-
810
817
  curr[name].push(...prev[name])
811
818
  }
812
819
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@k3000/store",
3
- "version": "1.0.2",
3
+ "version": "1.1.1",
4
4
  "description": "storage",
5
5
  "main": "generator.mjs",
6
6
  "scripts": {
package/test/1/index CHANGED
Binary file
package/test/1/type.ts CHANGED
@@ -29,6 +29,14 @@ interface AdminSet extends Array<Admin> {
29
29
  indexByUid(uid: String): Array<Admin>
30
30
  indexByValid(valid: Number): Array<Admin>
31
31
  indexByTime({after, before}): Array<Admin>
32
+ /**
33
+ * 重写push方法
34
+ */
35
+ push(...item: Array<Admin>): Array<Admin>
36
+ /**
37
+ * 重写unshift方法
38
+ */
39
+ unshift(...item: Array<Admin>): Array<Admin>
32
40
  /**
33
41
  * 分页查询
34
42
  */
@@ -76,6 +84,14 @@ interface LogSet extends Array<Log> {
76
84
  indexById(id: Number): Array<Log>
77
85
  indexByUid(uid: String): Array<Log>
78
86
  indexByTime({after, before}): Array<Log>
87
+ /**
88
+ * 重写push方法
89
+ */
90
+ push(...item: Array<Log>): Array<Log>
91
+ /**
92
+ * 重写unshift方法
93
+ */
94
+ unshift(...item: Array<Log>): Array<Log>
79
95
  /**
80
96
  * 分页查询
81
97
  */
@@ -141,6 +157,14 @@ interface Test {
141
157
  interface TestSet extends Array<Test> {
142
158
 
143
159
  indexById(id: Number): Array<Test>
160
+ /**
161
+ * 重写push方法
162
+ */
163
+ push(...item: Array<Test>): Array<Test>
164
+ /**
165
+ * 重写unshift方法
166
+ */
167
+ unshift(...item: Array<Test>): Array<Test>
144
168
  /**
145
169
  * 分页查询
146
170
  */
package/test/2/index CHANGED
Binary file
package/test/3/data CHANGED
Binary file
package/test/3/index CHANGED
Binary file
package/test/4/data CHANGED
Binary file
package/test/4/index CHANGED
Binary file
package/test/5/data CHANGED
Binary file
package/test/5/index CHANGED
Binary file
package/test/6/data CHANGED
Binary file
package/test/6/index CHANGED
Binary file
package/test/7/data CHANGED
Binary file
package/test/7/index CHANGED
Binary file