wrapperCommit.js 638 B

1234567891011121314151617181920212223242526272829303132
  1. var LodashWrapper = require('../internal/LodashWrapper');
  2. /**
  3. * Executes the chained sequence and returns the wrapped result.
  4. *
  5. * @name commit
  6. * @memberOf _
  7. * @category Chain
  8. * @returns {Object} Returns the new `lodash` wrapper instance.
  9. * @example
  10. *
  11. * var array = [1, 2];
  12. * var wrapped = _(array).push(3);
  13. *
  14. * console.log(array);
  15. * // => [1, 2]
  16. *
  17. * wrapped = wrapped.commit();
  18. * console.log(array);
  19. * // => [1, 2, 3]
  20. *
  21. * wrapped.last();
  22. * // => 3
  23. *
  24. * console.log(array);
  25. * // => [1, 2, 3]
  26. */
  27. function wrapperCommit() {
  28. return new LodashWrapper(this.value(), this.__chain__);
  29. }
  30. module.exports = wrapperCommit;