(
obj: Object | Array<any>,
oldPath: Array<string | number>,
newPath: Array<string | number>,
)
| 663 | }; |
| 664 | |
| 665 | const copyWithRename = ( |
| 666 | obj: Object | Array<any>, |
| 667 | oldPath: Array<string | number>, |
| 668 | newPath: Array<string | number>, |
| 669 | ): Object | Array<any> => { |
| 670 | if (oldPath.length !== newPath.length) { |
| 671 | console.warn('copyWithRename() expects paths of the same length'); |
| 672 | return; |
| 673 | } else { |
| 674 | for (let i = 0; i < newPath.length - 1; i++) { |
| 675 | if (oldPath[i] !== newPath[i]) { |
| 676 | console.warn( |
| 677 | 'copyWithRename() expects paths to be the same except for the deepest key', |
| 678 | ); |
| 679 | return; |
| 680 | } |
| 681 | } |
| 682 | } |
| 683 | return copyWithRenameImpl(obj, oldPath, newPath, 0); |
| 684 | }; |
| 685 | |
| 686 | const copyWithSetImpl = ( |
| 687 | obj: Object | Array<any>, |
no test coverage detected