Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make getPropertyByString synchronous #42

Merged
merged 2 commits into from
Oct 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading