Gitako/lib/util/clone.js
EnixCoda 18ce99c8f6 Squashed 'packages/pjax/' content from commit 8abb21e
git-subtree-dir: packages/pjax
git-subtree-split: 8abb21e1e9d899217b03c489c9b2d9ecd92074b5
2018-06-05 23:48:45 +08:00

13 lines
276 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
}