You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
855 B
31 lines
855 B
import H from 'highcharts';
|
|
|
|
const copyObject = function (original, copyArray) {
|
|
// Initialize the copy based on the original's type
|
|
const copy = H.isArray(original) ? [] : {};
|
|
|
|
// Callback function to iterate on array or object elements
|
|
function callback(value, key) {
|
|
// Copy the contents of objects
|
|
if (
|
|
H.isObject(value, !copyArray) &&
|
|
!H.isClass(value) &&
|
|
!H.isDOMElement(value)
|
|
) {
|
|
copy[key] = copyObject(value, copyArray); // recursive call
|
|
} else {
|
|
// Primitives are copied over directly
|
|
copy[key] = value;
|
|
}
|
|
}
|
|
|
|
if (H.isArray(original)) {
|
|
original.forEach((item, index) => callback(item, index));
|
|
} else {
|
|
H.objectEach(original, callback);
|
|
}
|
|
|
|
return copy;
|
|
};
|
|
|
|
export { copyObject };
|
|
|