mirror of
https://github.com/visgl/luma.gl.git
synced 2025-12-08 17:36:19 +00:00
17 lines
373 B
JavaScript
17 lines
373 B
JavaScript
// Recursively copies objects
|
|
export default function deepCopy(object) {
|
|
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;
|
|
}
|