@stackedapp/utils 1.12.0 → 1.12.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/dist/template.d.ts +2 -2
- package/dist/template.js +5 -1
- package/package.json +1 -1
package/dist/template.d.ts
CHANGED
|
@@ -10,9 +10,9 @@ export declare function renderTemplate(template: string | undefined, dynamic: Re
|
|
|
10
10
|
*
|
|
11
11
|
* eg. a condition high_score_pet-{{surfacerPlayerId}} with high_score_pet-12345
|
|
12
12
|
*/
|
|
13
|
-
export declare function replaceDynamicConditionKey(key: string, trackers: Record<string, any>): string;
|
|
13
|
+
export declare function replaceDynamicConditionKey(key: string, trackers: Record<string, any> | undefined): string;
|
|
14
14
|
/** this replaces all of the dynamic conditions.keys by calling replaceDynamicConditionKey */
|
|
15
|
-
export declare function replaceDynamicConditionKeys(conditions: Array<StackedDynamicCondition>, trackers: Record<string, any>): {
|
|
15
|
+
export declare function replaceDynamicConditionKeys(conditions: Array<StackedDynamicCondition>, trackers: Record<string, any> | undefined): {
|
|
16
16
|
key: string;
|
|
17
17
|
compareTo: string | number | boolean;
|
|
18
18
|
operator: "==" | "!=" | ">" | ">=" | "<" | "<=" | "has" | "not_has";
|
package/dist/template.js
CHANGED
|
@@ -39,7 +39,11 @@ function renderTemplate(template, dynamic) {
|
|
|
39
39
|
* eg. a condition high_score_pet-{{surfacerPlayerId}} with high_score_pet-12345
|
|
40
40
|
*/
|
|
41
41
|
function replaceDynamicConditionKey(key, trackers) {
|
|
42
|
-
|
|
42
|
+
if (!key)
|
|
43
|
+
return '';
|
|
44
|
+
if (!trackers)
|
|
45
|
+
return key;
|
|
46
|
+
return key.replace(/\{\{([a-zA-Z_][a-zA-Z0-9_]*)\}\}/g, (match, p1) => {
|
|
43
47
|
const value = trackers[p1];
|
|
44
48
|
return value !== undefined ? String(value) : match;
|
|
45
49
|
});
|