Merge pull request #4239 from crazyserver/MOBILE-4653

MOBILE-4653 chore: Move deprecated useful function
main
Dani Palou 2024-11-18 16:13:22 +01:00 committed by GitHub
commit 024346aff9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 20 additions and 9 deletions

View File

@ -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);
}
/**

View File

@ -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.
*