single level clone, returning a new object with same top fields. This will share sub objects and arrays
(obj: T)
| 610 | |
| 611 | /** single level clone, returning a new object with same top fields. This will share sub objects and arrays */ |
| 612 | static clone<T>(obj: T): T { |
| 613 | if (obj === null || obj === undefined || typeof(obj) !== 'object') { |
| 614 | return obj; |
| 615 | } |
| 616 | // return Object.assign({}, obj); |
| 617 | if (obj instanceof Array) { |
| 618 | // eslint-disable-next-line @typescript-eslint/no-explicit-any |
| 619 | return [...obj] as any; |
| 620 | } |
| 621 | return {...obj}; |
| 622 | } |
| 623 | |
| 624 | /** |
| 625 | * Recursive clone version that returns a full copy, checking for nested objects and arrays ONLY. |
no outgoing calls
no test coverage detected