Mangler.rename() - DarthJDG/Mangler.js GitHub Wiki
Renames matching strings in arrays or object property names.
Mangler.rename(object, dictionary)| Parameter | Type | Default | Description |
|---|---|---|---|
| object | String Array.String Object Array.Object |
The value, object or array to rename. | |
| dictionary | Object | Dictionary of strings to replace. |
Returns object after processing.
The dictionary is a simple object containing string pairs to rename:
{
'rename this string': 'to this string'
}Depending on the type of object, rename works differently:
| Type | Action |
|---|---|
| string | Returns the matching string in the dictionary if found, otherwise returns the original. |
| object | Renames all matching object property names and returns the object. |
| array | Processes each items individually according to their type above and returns the processed array. |
| mangler object | Processes each items individually according to their type above and returns the processed mangler object. |
Rename doesn't process objects recursively, it only changes top-level properties.