🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
28 lines
375 B
JavaScript
Executable File
28 lines
375 B
JavaScript
Executable File
'use strict';
|
|
|
|
/**
|
|
* Clone helper
|
|
*
|
|
* Clone an array or object
|
|
*
|
|
* @param items
|
|
* @returns {*}
|
|
*/
|
|
module.exports = function clone(items) {
|
|
let cloned;
|
|
|
|
if (Array.isArray(items)) {
|
|
cloned = [];
|
|
|
|
cloned.push(...items);
|
|
} else {
|
|
cloned = {};
|
|
|
|
Object.keys(items).forEach((prop) => {
|
|
cloned[prop] = items[prop];
|
|
});
|
|
}
|
|
|
|
return cloned;
|
|
};
|