diff --git a/common/changes/@educorvi/rita/develop_2024-10-21-09-49.json b/common/changes/@educorvi/rita/develop_2024-10-21-09-49.json new file mode 100644 index 0000000..468a7bc --- /dev/null +++ b/common/changes/@educorvi/rita/develop_2024-10-21-09-49.json @@ -0,0 +1,10 @@ +{ + "changes": [ + { + "packageName": "@educorvi/rita", + "comment": "make `getPropertyByString` synchronous", + "type": "patch" + } + ], + "packageName": "@educorvi/rita" +} \ No newline at end of file diff --git a/rita-core/src/logicElements/Atom.ts b/rita-core/src/logicElements/Atom.ts index 981227c..8dc56e4 100644 --- a/rita-core/src/logicElements/Atom.ts +++ b/rita-core/src/logicElements/Atom.ts @@ -45,12 +45,12 @@ export class Atom extends Formula { * @param defaultVal default value to return if path is not found * @param context the context of the formula */ - static async getPropertyByString( + static getPropertyByString( object: any, path: string, defaultVal?: FormulaResults | Array, context?: Formula - ): Promise { + ): FormulaResults | FormulaResults[] { path = path.replace(/\[(\w+)]/g, '.$1'); // convert indexes to properties path = path.replace(/^\./, ''); // strip a leading dot const a = path.split('.'); @@ -75,9 +75,7 @@ export class Atom extends Formula { * @param object object * @private */ - getPropertyByString( - object: any - ): Promise { + getPropertyByString(object: any): FormulaResults | FormulaResults[] { return Atom.getPropertyByString( object, this.path, @@ -104,7 +102,7 @@ export class Atom extends Formula { data: Record ): Promise { let val: FormulaResults | FormulaResults[] = - await this.getPropertyByString(data); + this.getPropertyByString(data); if (typeof val === 'string' && this.isDate) { return parseDate(val, this);