@k3000/store 1.5.3 → 1.5.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/README.md CHANGED
@@ -229,4 +229,7 @@ storage.admin.remove(...storage.admin.filter(admin => admin.usn.startsWith('test
229
229
 
230
230
  **保存:**
231
231
 
232
- `storage.close()` // 关闭并保存
232
+ ```
233
+ import {close} from './test/index.mjs'
234
+ close() // 关闭并保存
235
+ ```
package/generator.mjs CHANGED
@@ -938,7 +938,7 @@ function submit() {
938
938
  clipTypeTs(this.typePath, this.curr.struct)
939
939
  clipIndexMjs(this.currPath, this.curr.struct)
940
940
 
941
- const version = readdirSync(this.dir).map(v => parseFloat(v) || 0).sort(sort).pop()
941
+ const version = readdirSync(this.dir).map(v => parseFloat(v) || 0).sort().pop()
942
942
 
943
943
  writeFileSync(`${this.dir}index.mjs`, `
944
944
  const index = import.meta.url.indexOf('?')
@@ -1195,6 +1195,7 @@ const clipIndex = (name, key, k, v) => {
1195
1195
 
1196
1196
  const clipConst = struct => Array.from(new Set(Object.values(struct)
1197
1197
  .map(struct => Object.keys(struct)).flat()))
1198
+ .sort()
1198
1199
  .map(key => `const $${key} = '${key}'`)
1199
1200
  .join('\n')
1200
1201
 
@@ -1210,11 +1211,7 @@ const clipProperties = (name, key, update, [k, v]) => `
1210
1211
  }` : clipIndex(name, key, k, v)},
1211
1212
  },`
1212
1213
 
1213
- const sort = (a, b) => a - b
1214
-
1215
- const sort2 = (a, b) => a > b ? 1 : a < b ? -1 : 0
1216
-
1217
- const sort3 = ([a], [b]) => a > b ? 1 : a < b ? -1 : 0
1214
+ const sort2 = ([a], [b]) => a.localeCompare(b)
1218
1215
 
1219
1216
  const clipEntity = ([key, value]) => {
1220
1217
 
@@ -1228,7 +1225,7 @@ class ${name} extends Entity {
1228
1225
  static name = '${key}'
1229
1226
 
1230
1227
  static create(_) {
1231
- ${Object.entries(value).sort(sort3).map(clipStatic.bind(null, name)).filter(str => str).join('\n')}
1228
+ ${Object.entries(value).sort(sort2).map(clipStatic.bind(null, name)).filter(str => str).join('\n')}
1232
1229
  return _
1233
1230
  }
1234
1231
 
@@ -1241,7 +1238,7 @@ ${Object.entries(value).sort(sort3).map(clipStatic.bind(null, name)).filter(str
1241
1238
  enumerable: false,
1242
1239
  configurable: false,
1243
1240
  get: () => this[position],
1244
- },${Object.entries(value).sort(sort3).map(clipProperties.bind(null, name, key, update)).join('')}
1241
+ },${Object.entries(value).sort(sort2).map(clipProperties.bind(null, name, key, update)).join('')}
1245
1242
  })
1246
1243
  }
1247
1244
  ${update ? `
@@ -1339,7 +1336,7 @@ const clipTypeTs = (path, struct) => writeFileSync(path, `${Object.entries(struc
1339
1336
 
1340
1337
  return `
1341
1338
  interface ${key} {
1342
- ${Object.entries(value).map(([key, value]) => `
1339
+ ${Object.entries(value).sort(sort2).map(([key, value]) => `
1343
1340
  /**
1344
1341
  * ${commentRemark(value.remark)}
1345
1342
  */
@@ -1448,7 +1445,7 @@ export default function upgrade(name, {
1448
1445
  mkdirSync(dir)
1449
1446
  }
1450
1447
 
1451
- let v = readdirSync(dir).map(v => parseFloat(v) || 0).sort(sort).pop()
1448
+ let v = readdirSync(dir).map(v => parseFloat(v) || 0).sort().pop()
1452
1449
 
1453
1450
  let prev
1454
1451
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@k3000/store",
3
- "version": "1.5.3",
3
+ "version": "1.5.5",
4
4
  "description": "storage",
5
5
  "main": "generator.mjs",
6
6
  "scripts": {