_setWrapToString.js 845 B

123456789101112131415161718192021
  1. import getWrapDetails from './_getWrapDetails.js';
  2. import insertWrapDetails from './_insertWrapDetails.js';
  3. import setToString from './_setToString.js';
  4. import updateWrapDetails from './_updateWrapDetails.js';
  5. /**
  6. * Sets the `toString` method of `wrapper` to mimic the source of `reference`
  7. * with wrapper details in a comment at the top of the source body.
  8. *
  9. * @private
  10. * @param {Function} wrapper The function to modify.
  11. * @param {Function} reference The reference function.
  12. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  13. * @returns {Function} Returns `wrapper`.
  14. */
  15. function setWrapToString(wrapper, reference, bitmask) {
  16. var source = (reference + '');
  17. return setToString(wrapper, insertWrapDetails(source, updateWrapDetails(getWrapDetails(source), bitmask)));
  18. }
  19. export default setWrapToString;