_wrapperClone.js 658B

123456789101112131415161718192021222324
  1. var LazyWrapper = require('./_LazyWrapper'),
  2. LodashWrapper = require('./_LodashWrapper'),
  3. copyArray = require('./_copyArray');
  4. /**
  5. * Creates a clone of `wrapper`.
  6. *
  7. * @private
  8. * @param {Object} wrapper The wrapper to clone.
  9. * @returns {Object} Returns the cloned wrapper.
  10. */
  11. function wrapperClone(wrapper) {
  12. if (wrapper instanceof LazyWrapper) {
  13. return wrapper.clone();
  14. }
  15. var result = new LodashWrapper(wrapper.__wrapped__, wrapper.__chain__);
  16. result.__actions__ = copyArray(wrapper.__actions__);
  17. result.__index__ = wrapper.__index__;
  18. result.__values__ = wrapper.__values__;
  19. return result;
  20. }
  21. module.exports = wrapperClone;