extra-disk-store 0.7.0 → 0.7.2
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/lib/converters/index-key-converter.d.ts +1 -1
- package/lib/converters/index-key-converter.js +4 -1
- package/lib/converters/index-key-converter.js.map +1 -1
- package/lib/converters/json-key-converter.d.ts +1 -1
- package/lib/converters/json-key-converter.js +4 -3
- package/lib/converters/json-key-converter.js.map +1 -1
- package/package.json +4 -3
- package/src/converters/index-key-converter.ts +6 -2
- package/src/converters/json-key-converter.ts +5 -4
- package/src/types.ts +4 -0
|
@@ -6,7 +6,10 @@ export class IndexKeyConverter {
|
|
|
6
6
|
return value.toString(this.radix);
|
|
7
7
|
}
|
|
8
8
|
fromString(value) {
|
|
9
|
-
|
|
9
|
+
const result = Number.parseInt(value, this.radix);
|
|
10
|
+
return Number.isInteger(result)
|
|
11
|
+
? result
|
|
12
|
+
: undefined;
|
|
10
13
|
}
|
|
11
14
|
}
|
|
12
15
|
//# sourceMappingURL=index-key-converter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index-key-converter.js","sourceRoot":"","sources":["../../src/converters/index-key-converter.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,iBAAiB;IAC5B,YAAoB,QAAgB,EAAE;QAAlB,UAAK,GAAL,KAAK,CAAa;IAAG,CAAC;IAE1C,QAAQ,CAAC,KAAa;QACpB,OAAO,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;IACnC,CAAC;IAED,UAAU,CAAC,KAAa;QACtB,
|
|
1
|
+
{"version":3,"file":"index-key-converter.js","sourceRoot":"","sources":["../../src/converters/index-key-converter.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,iBAAiB;IAC5B,YAAoB,QAAgB,EAAE;QAAlB,UAAK,GAAL,KAAK,CAAa;IAAG,CAAC;IAE1C,QAAQ,CAAC,KAAa;QACpB,OAAO,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;IACnC,CAAC;IAED,UAAU,CAAC,KAAa;QACtB,MAAM,MAAM,GAAG,MAAM,CAAC,QAAQ,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,CAAA;QAEjD,OAAO,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC;YAC1B,CAAC,CAAC,MAAM;YACR,CAAC,CAAC,SAAS,CAAA;IAClB,CAAC;CACF"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import { getResult } from 'return-style';
|
|
1
2
|
export class JSONKeyConverter {
|
|
2
|
-
fromString(value) {
|
|
3
|
-
return JSON.parse(value);
|
|
4
|
-
}
|
|
5
3
|
toString(value) {
|
|
6
4
|
return JSON.stringify(value);
|
|
7
5
|
}
|
|
6
|
+
fromString(value) {
|
|
7
|
+
return getResult(() => JSON.parse(value));
|
|
8
|
+
}
|
|
8
9
|
}
|
|
9
10
|
//# sourceMappingURL=json-key-converter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"json-key-converter.js","sourceRoot":"","sources":["../../src/converters/json-key-converter.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"json-key-converter.js","sourceRoot":"","sources":["../../src/converters/json-key-converter.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAExC,MAAM,OAAO,gBAAgB;IAC3B,QAAQ,CAAC,KAAQ;QACf,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAA;IAC9B,CAAC;IAED,UAAU,CAAC,KAAa;QACtB,OAAO,SAAS,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAA;IAC3C,CAAC;CACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "extra-disk-store",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.2",
|
|
4
4
|
"description": "",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"files": [
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"vitest": "^2.1.1"
|
|
58
58
|
},
|
|
59
59
|
"dependencies": {
|
|
60
|
-
"@blackglory/better-sqlite3-migrations": "^0.1.
|
|
60
|
+
"@blackglory/better-sqlite3-migrations": "^0.1.19",
|
|
61
61
|
"@blackglory/prelude": "^0.3.4",
|
|
62
62
|
"@mongodb-js/zstd": "^1.2.0",
|
|
63
63
|
"better-sqlite3": "^11.3.0",
|
|
@@ -68,6 +68,7 @@
|
|
|
68
68
|
"extra-utils": "^5.6.0",
|
|
69
69
|
"iterable-operator": "^5.0.0",
|
|
70
70
|
"lz4-wasm-nodejs": "^0.9.2",
|
|
71
|
-
"migration-files": "^0.4.3"
|
|
71
|
+
"migration-files": "^0.4.3",
|
|
72
|
+
"return-style": "^3.0.1"
|
|
72
73
|
}
|
|
73
74
|
}
|
|
@@ -7,7 +7,11 @@ export class IndexKeyConverter implements IKeyConverter<number> {
|
|
|
7
7
|
return value.toString(this.radix)
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
fromString(value: string): number {
|
|
11
|
-
|
|
10
|
+
fromString(value: string): number | undefined {
|
|
11
|
+
const result = Number.parseInt(value, this.radix)
|
|
12
|
+
|
|
13
|
+
return Number.isInteger(result)
|
|
14
|
+
? result
|
|
15
|
+
: undefined
|
|
12
16
|
}
|
|
13
17
|
}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { IKeyConverter } from '@src/types.js'
|
|
2
|
+
import { getResult } from 'return-style'
|
|
2
3
|
|
|
3
4
|
export class JSONKeyConverter<T> implements IKeyConverter<T> {
|
|
4
|
-
fromString(value: string): T {
|
|
5
|
-
return JSON.parse(value)
|
|
6
|
-
}
|
|
7
|
-
|
|
8
5
|
toString(value: T): string {
|
|
9
6
|
return JSON.stringify(value)
|
|
10
7
|
}
|
|
8
|
+
|
|
9
|
+
fromString(value: string): T | undefined {
|
|
10
|
+
return getResult(() => JSON.parse(value))
|
|
11
|
+
}
|
|
11
12
|
}
|
package/src/types.ts
CHANGED
|
@@ -2,6 +2,8 @@ import { Awaitable } from '@blackglory/prelude'
|
|
|
2
2
|
|
|
3
3
|
export interface IKeyConverter<T> {
|
|
4
4
|
toString: (value: T) => string
|
|
5
|
+
|
|
6
|
+
// `undefined`用于遍历key时的过滤.
|
|
5
7
|
fromString: (value: string) => T | undefined
|
|
6
8
|
}
|
|
7
9
|
|
|
@@ -12,6 +14,8 @@ export interface IValueConverter<T> {
|
|
|
12
14
|
|
|
13
15
|
export interface IKeyAsyncConverter<T> {
|
|
14
16
|
toString: (value: T) => Awaitable<string>
|
|
17
|
+
|
|
18
|
+
// `undefined`用于遍历key时的过滤.
|
|
15
19
|
fromString: (value: string) => Awaitable<T | undefined>
|
|
16
20
|
}
|
|
17
21
|
|