_setWrapToString.js 847 B

123456789101112131415161718192021
  1. var getWrapDetails = require('./_getWrapDetails'),
  2. insertWrapDetails = require('./_insertWrapDetails'),
  3. setToString = require('./_setToString'),
  4. updateWrapDetails = require('./_updateWrapDetails');
  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. module.exports = setWrapToString;