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.
25 lines
388 B
25 lines
388 B
/**
|
|
* Clones the given value.
|
|
*/
|
|
exports.clone = function(value)
|
|
{
|
|
if (value === undefined)
|
|
{
|
|
return undefined;
|
|
}
|
|
else if (Number.isNaN(value))
|
|
{
|
|
return NaN;
|
|
}
|
|
else if (typeof structuredClone === 'function')
|
|
{
|
|
// Available in Node >= 18.
|
|
// eslint-disable-next-line no-undef
|
|
return structuredClone(value);
|
|
}
|
|
else
|
|
{
|
|
return JSON.parse(JSON.stringify(value));
|
|
}
|
|
};
|