( object: Object, oldPath: Array<string | number>, newPath: Array<string | number>, )
| 647 | } |
| 648 | |
| 649 | export function renamePathInObject( |
| 650 | object: Object, |
| 651 | oldPath: Array<string | number>, |
| 652 | newPath: Array<string | number>, |
| 653 | ) { |
| 654 | const length = oldPath.length; |
| 655 | if (object != null) { |
| 656 | const parent = getInObject(object, oldPath.slice(0, length - 1)); |
| 657 | if (parent) { |
| 658 | const lastOld = oldPath[length - 1]; |
| 659 | const lastNew = newPath[length - 1]; |
| 660 | parent[lastNew] = parent[lastOld]; |
| 661 | if (isArray(parent)) { |
| 662 | parent.splice(((lastOld: any): number), 1); |
| 663 | } else { |
| 664 | delete parent[lastOld]; |
| 665 | } |
| 666 | } |
| 667 | } |
| 668 | } |
| 669 | |
| 670 | export function setInObject( |
| 671 | object: Object, |
no test coverage detected