@omnia/fx-models 8.0.26-dev → 8.0.27-dev
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/Dictionary.d.ts +18 -19
- package/Dictionary.js +16 -24
- package/Layout.d.ts +1 -1
- package/identities/UserTypeSettings.d.ts +1 -0
- package/identities/UserTypeSettings.js +3 -0
- package/package.json +1 -1
package/Dictionary.d.ts
CHANGED
|
@@ -1,28 +1,27 @@
|
|
|
1
|
+
export type DictionarySupportedKeys = string | number | symbol;
|
|
1
2
|
export interface IDictionary<TValue> {
|
|
2
3
|
/**
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
getValue
|
|
4
|
+
* Returns the value of the key, or null if it does not exist.
|
|
5
|
+
*/
|
|
6
|
+
getValue(key: DictionarySupportedKeys): TValue | null;
|
|
6
7
|
/**
|
|
7
|
-
* Get the value of the specified key
|
|
8
|
-
|
|
9
|
-
getOrSetInitialValue
|
|
8
|
+
* Get the value of the specified key, or use the supplied factory to create and set the value if it doesn't exist.
|
|
9
|
+
*/
|
|
10
|
+
getOrSetInitialValue(key: DictionarySupportedKeys, initialValueFactory: () => TValue): TValue;
|
|
10
11
|
/**
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
setValue
|
|
12
|
+
* Changes the value of the key.
|
|
13
|
+
*/
|
|
14
|
+
setValue(key: DictionarySupportedKeys, value: TValue): void;
|
|
14
15
|
/**
|
|
15
|
-
* All keys
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
* All keys.
|
|
17
|
+
*/
|
|
18
|
+
keys: DictionarySupportedKeys[];
|
|
18
19
|
}
|
|
19
20
|
export declare class Dictionary<TValue> implements IDictionary<TValue> {
|
|
20
21
|
private _bagData;
|
|
21
|
-
constructor(
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
getOrSetInitialValue: (key: string, initialValueFactory: () => TValue) => TValue;
|
|
27
|
-
get keys(): Array<string>;
|
|
22
|
+
constructor(initialData?: Record<DictionarySupportedKeys, TValue>);
|
|
23
|
+
getValue: (key: DictionarySupportedKeys) => TValue | null;
|
|
24
|
+
setValue: (key: DictionarySupportedKeys, value: TValue) => void;
|
|
25
|
+
getOrSetInitialValue: (key: DictionarySupportedKeys, initialValueFactory: () => TValue) => TValue;
|
|
26
|
+
get keys(): DictionarySupportedKeys[];
|
|
28
27
|
}
|
package/Dictionary.js
CHANGED
|
@@ -2,41 +2,33 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Dictionary = void 0;
|
|
4
4
|
class Dictionary {
|
|
5
|
-
constructor(
|
|
6
|
-
this._bagData = _bagData;
|
|
5
|
+
constructor(initialData = {}) {
|
|
7
6
|
this.getValue = (key) => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
}
|
|
12
|
-
return result;
|
|
7
|
+
// Normalize the key to lowercase for consistency.
|
|
8
|
+
const lowerKey = String(key).toLowerCase();
|
|
9
|
+
return this._bagData[lowerKey] || null;
|
|
13
10
|
};
|
|
14
11
|
this.setValue = (key, value) => {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
const lowerKey = key.toLowerCase();
|
|
19
|
-
this._bagData[lowerKey] = value;
|
|
12
|
+
// Normalize the key to lowercase for consistency.
|
|
13
|
+
this._bagData[String(key).toLowerCase()] = value;
|
|
20
14
|
};
|
|
21
15
|
this.getOrSetInitialValue = (key, initialValueFactory) => {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}
|
|
16
|
+
// Normalize the key to lowercase for consistency.
|
|
17
|
+
const lowerKey = String(key).toLowerCase();
|
|
18
|
+
let value = this._bagData[lowerKey];
|
|
19
|
+
if (value === undefined && initialValueFactory) {
|
|
20
|
+
// If the key doesn't exist and there's an initialValueFactory, create and set the value.
|
|
28
21
|
value = initialValueFactory();
|
|
29
|
-
this.setValue(
|
|
22
|
+
this.setValue(lowerKey, value);
|
|
30
23
|
}
|
|
31
24
|
return value;
|
|
32
25
|
};
|
|
26
|
+
// Initialize the _bagData property with a copy of the initial data.
|
|
27
|
+
this._bagData = Object.assign({}, initialData);
|
|
33
28
|
}
|
|
34
29
|
get keys() {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
result = Object.keys(this._bagData);
|
|
38
|
-
}
|
|
39
|
-
return result;
|
|
30
|
+
// Get an array of keys from the _bagData object.
|
|
31
|
+
return Object.keys(this._bagData);
|
|
40
32
|
}
|
|
41
33
|
}
|
|
42
34
|
exports.Dictionary = Dictionary;
|
package/Layout.d.ts
CHANGED