clone.js 309 B

123456789101112
  1. var isObject = require('./isObject.js');
  2. var isArray = require('./isArray.js');
  3. var extend = require('./extend.js');
  4. // Create a (shallow-cloned) duplicate of an object.
  5. function clone(obj) {
  6. if (!isObject(obj)) return obj;
  7. return isArray(obj) ? obj.slice() : extend({}, obj);
  8. }
  9. module.exports = clone;