-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…5086) Co-authored-by: Diego Cardoso <[email protected]>
- Loading branch information
1 parent
bec3f9a
commit cb93359
Showing
3 changed files
with
75 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
export function inflateFunctions(config) { | ||
if ( | ||
// Check if param is a primitive/null/undefined value | ||
!(config instanceof Object) || | ||
// Check if param is a plain object (not an array or HC object) | ||
config.constructor !== Object | ||
) { | ||
return; | ||
} | ||
Object.entries(config).forEach(([attr, targetProperty]) => { | ||
if (attr.startsWith('_fn_') && (typeof targetProperty === 'string' || targetProperty instanceof String)) { | ||
try { | ||
// eslint-disable-next-line no-eval | ||
config[attr.substr(4)] = eval(`(${targetProperty})`); | ||
} catch (e) { | ||
// eslint-disable-next-line no-eval | ||
config[attr.substr(4)] = eval(`(function(){${targetProperty}})`); | ||
} | ||
delete config[attr]; | ||
} else if (targetProperty instanceof Object) { | ||
inflateFunctions(targetProperty); | ||
} | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters