mirror of
https://github.com/visgl/luma.gl.git
synced 2026-01-25 14:08:58 +00:00
17 lines
396 B
TypeScript
17 lines
396 B
TypeScript
// Recursively copies objects
|
|
export default function deepCopy(object: Record<string, any>) {
|
|
if (Array.isArray(object)) {
|
|
return object.map((element) => deepCopy(element));
|
|
}
|
|
|
|
if (object !== null && typeof object === 'object') {
|
|
const newObject = {};
|
|
for (const key in object) {
|
|
newObject[key] = deepCopy(object[key]);
|
|
}
|
|
return newObject;
|
|
}
|
|
|
|
return object;
|
|
}
|