copy.js 270 Bytes Raw Blame History Permalink 1 2 3 4 5 6 7 8 9 10 var each = require('./each'), isArray = require('./isArray') module.exports = function copy(obj, deep) { var result = isArray(obj) ? [] : {} each(obj, function(val, key) { result[key] = (deep && typeof val == 'object') ? copy(val, deep) : val }) return result }