Skip to content

Commit

Permalink
Merge pull request #42 from educorvi/develop
Browse files Browse the repository at this point in the history
make `getPropertyByString` synchronous
  • Loading branch information
neferin12 authored Oct 21, 2024
2 parents 40832b0 + c602ea8 commit 1441ac9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
10 changes: 10 additions & 0 deletions common/changes/@educorvi/rita/develop_2024-10-21-09-49.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@educorvi/rita",
"comment": "make `getPropertyByString` synchronous",
"type": "patch"
}
],
"packageName": "@educorvi/rita"
}
10 changes: 4 additions & 6 deletions rita-core/src/logicElements/Atom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<FormulaResults>,
context?: Formula
): Promise<FormulaResults | FormulaResults[]> {
): FormulaResults | FormulaResults[] {
path = path.replace(/\[(\w+)]/g, '.$1'); // convert indexes to properties
path = path.replace(/^\./, ''); // strip a leading dot
const a = path.split('.');
Expand All @@ -75,9 +75,7 @@ export class Atom extends Formula {
* @param object object
* @private
*/
getPropertyByString(
object: any
): Promise<FormulaResults | FormulaResults[]> {
getPropertyByString(object: any): FormulaResults | FormulaResults[] {
return Atom.getPropertyByString(
object,
this.path,
Expand All @@ -104,7 +102,7 @@ export class Atom extends Formula {
data: Record<string, any>
): Promise<FormulaResults | FormulaResults[]> {
let val: FormulaResults | FormulaResults[] =
await this.getPropertyByString(data);
this.getPropertyByString(data);

if (typeof val === 'string' && this.isDate) {
return parseDate(val, this);
Expand Down

0 comments on commit 1441ac9

Please sign in to comment.