(o: T)
| 109 | * @category Global |
| 110 | */ |
| 111 | export function deepCopy<T>(o: T): T { |
| 112 | if (o == null || typeof o !== 'object') { |
| 113 | return o; |
| 114 | } |
| 115 | if (Array.isArray(o)) { |
| 116 | return (o as any).map(v => deepCopy(v)); |
| 117 | } |
| 118 | if (isDict(o)) { |
| 119 | return Object.keys(o).reduce((newO, k) => { |
| 120 | newO[k] = deepCopy(o[k]); |
| 121 | return newO; |
| 122 | }, {} as T); |
| 123 | } |
| 124 | return o; |
| 125 | } |
| 126 | |
| 127 | /** |
| 128 | * @internal please do not use. |
no test coverage detected