@microsoft/ccf-app 5.0.0-dev3 → 5.0.0-dev4
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/kv.d.ts +3 -2
- package/kv.js +17 -12
- package/package.json +3 -3
package/kv.d.ts
CHANGED
|
@@ -36,10 +36,11 @@
|
|
|
36
36
|
import { KvMap } from "./global.js";
|
|
37
37
|
import { DataConverter } from "./converters.js";
|
|
38
38
|
export declare class TypedKvMap<K, V> {
|
|
39
|
-
private
|
|
39
|
+
private nameOrMap;
|
|
40
40
|
private kt;
|
|
41
41
|
private vt;
|
|
42
|
-
|
|
42
|
+
private _kv;
|
|
43
|
+
constructor(nameOrMap: string | KvMap, kt: DataConverter<K>, vt: DataConverter<V>);
|
|
43
44
|
has(key: K): boolean;
|
|
44
45
|
get(key: K): V | undefined;
|
|
45
46
|
getVersionOfPreviousWrite(key: K): number | undefined;
|
package/kv.js
CHANGED
|
@@ -37,41 +37,47 @@
|
|
|
37
37
|
*/
|
|
38
38
|
import { ccf } from "./global.js";
|
|
39
39
|
export class TypedKvMap {
|
|
40
|
-
|
|
41
|
-
this.
|
|
40
|
+
_kv() {
|
|
41
|
+
const kvMap = typeof this.nameOrMap === "string"
|
|
42
|
+
? ccf.kv[this.nameOrMap]
|
|
43
|
+
: this.nameOrMap;
|
|
44
|
+
return kvMap;
|
|
45
|
+
}
|
|
46
|
+
constructor(nameOrMap, kt, vt) {
|
|
47
|
+
this.nameOrMap = nameOrMap;
|
|
42
48
|
this.kt = kt;
|
|
43
49
|
this.vt = vt;
|
|
44
50
|
}
|
|
45
51
|
has(key) {
|
|
46
|
-
return this.
|
|
52
|
+
return this._kv().has(this.kt.encode(key));
|
|
47
53
|
}
|
|
48
54
|
get(key) {
|
|
49
|
-
const v = this.
|
|
55
|
+
const v = this._kv().get(this.kt.encode(key));
|
|
50
56
|
return v === undefined ? undefined : this.vt.decode(v);
|
|
51
57
|
}
|
|
52
58
|
getVersionOfPreviousWrite(key) {
|
|
53
|
-
return this.
|
|
59
|
+
return this._kv().getVersionOfPreviousWrite(this.kt.encode(key));
|
|
54
60
|
}
|
|
55
61
|
set(key, value) {
|
|
56
|
-
this.
|
|
62
|
+
this._kv().set(this.kt.encode(key), this.vt.encode(value));
|
|
57
63
|
return this;
|
|
58
64
|
}
|
|
59
65
|
delete(key) {
|
|
60
|
-
this.
|
|
66
|
+
this._kv().delete(this.kt.encode(key));
|
|
61
67
|
}
|
|
62
68
|
clear() {
|
|
63
|
-
this.
|
|
69
|
+
this._kv().clear();
|
|
64
70
|
}
|
|
65
71
|
forEach(callback) {
|
|
66
72
|
let kt = this.kt;
|
|
67
73
|
let vt = this.vt;
|
|
68
74
|
let typedMap = this;
|
|
69
|
-
this.
|
|
75
|
+
this._kv().forEach(function (raw_v, raw_k, table) {
|
|
70
76
|
callback(vt.decode(raw_v), kt.decode(raw_k), typedMap);
|
|
71
77
|
});
|
|
72
78
|
}
|
|
73
79
|
get size() {
|
|
74
|
-
return this.
|
|
80
|
+
return this._kv().size;
|
|
75
81
|
}
|
|
76
82
|
}
|
|
77
83
|
/**
|
|
@@ -88,8 +94,7 @@ export class TypedKvMap {
|
|
|
88
94
|
* @param vt The converter to use for map values.
|
|
89
95
|
*/
|
|
90
96
|
export function typedKv(nameOrMap, kt, vt) {
|
|
91
|
-
|
|
92
|
-
return new TypedKvMap(kvMap, kt, vt);
|
|
97
|
+
return new TypedKvMap(nameOrMap, kt, vt);
|
|
93
98
|
}
|
|
94
99
|
/**
|
|
95
100
|
* @inheritDoc global!CCF.kv
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@microsoft/ccf-app",
|
|
3
|
-
"version": "5.0.0-
|
|
3
|
+
"version": "5.0.0-dev4",
|
|
4
4
|
"description": "CCF app support package",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"files": [
|
|
@@ -25,11 +25,11 @@
|
|
|
25
25
|
"chai": "^4.3.4",
|
|
26
26
|
"colors": "1.4.0",
|
|
27
27
|
"cross-env": "^7.0.3",
|
|
28
|
+
"get-func-name": "3.0.0",
|
|
28
29
|
"mocha": "^10.0.0",
|
|
29
30
|
"node-forge": "^1.2.0",
|
|
30
31
|
"ts-node": "^10.4.0",
|
|
31
32
|
"typedoc": "^0.25.0",
|
|
32
|
-
"typescript": "^5.0.2"
|
|
33
|
-
"get-func-name": "3.0.0"
|
|
33
|
+
"typescript": "^5.0.2"
|
|
34
34
|
}
|
|
35
35
|
}
|