14 lines
281 B
JavaScript
14 lines
281 B
JavaScript
module.exports = function(obj) {
|
|
/* istanbul ignore if */
|
|
if (null === obj || "object" !== typeof obj) {
|
|
return obj;
|
|
}
|
|
var copy = obj.constructor();
|
|
for (var attr in obj) {
|
|
if (obj.hasOwnProperty(attr)) {
|
|
copy[attr] = obj[attr];
|
|
}
|
|
}
|
|
return copy;
|
|
};
|