initCloneObject.js 363 B

12345678910111213141516
  1. /**
  2. * Initializes an object clone.
  3. *
  4. * @private
  5. * @param {Object} object The object to clone.
  6. * @returns {Object} Returns the initialized clone.
  7. */
  8. function initCloneObject(object) {
  9. var Ctor = object.constructor;
  10. if (!(typeof Ctor == 'function' && Ctor instanceof Ctor)) {
  11. Ctor = Object;
  12. }
  13. return new Ctor;
  14. }
  15. module.exports = initCloneObject;