Skip to content

Commit

Permalink
MOBILE-4653 chore: Move deprecated useful function
Browse files Browse the repository at this point in the history
  • Loading branch information
crazyserver committed Nov 18, 2024
1 parent 84781a7 commit aca63d6
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 9 deletions.
11 changes: 2 additions & 9 deletions src/core/services/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -667,17 +667,10 @@ export class CoreUtilsProvider {
* @param data Object.
* @param prefix Prefix to add.
* @returns Prefixed object.
* @deprecated since 5.0. Not used anymore
* @deprecated since 5.0. Use CoreObject.prefixKeys instead.
*/
prefixKeys(data: Record<string, unknown>, prefix: string): Record<string, unknown> {
const newObj = {};
const keys = Object.keys(data);

keys.forEach((key) => {
newObj[prefix + key] = data[key];
});

return newObj;
return CoreObject.prefixKeys(data, prefix);
}

/**
Expand Down
18 changes: 18 additions & 0 deletions src/core/singletons/object.ts
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,24 @@ export class CoreObject {
return result;
}

/**
* Add a prefix to all the keys in an object.
*
* @param data Object.
* @param prefix Prefix to add.
* @returns Prefixed object.
*/
static prefixKeys(data: Record<string, unknown>, prefix: string): Record<string, unknown> {
const newObj = {};
const keys = Object.keys(data);

keys.forEach((key) => {
newObj[prefix + key] = data[key];
});

return newObj;
}

/**
* Function to enumerate enum keys.
*
Expand Down

0 comments on commit aca63d6

Please sign in to comment.