_baseSetToString.js 641 B

1234567891011121314151617181920212223
  1. var constant = require('./constant'),
  2. defineProperty = require('./_defineProperty'),
  3. identity = require('./identity');
  4. /**
  5. * The base implementation of `setToString` without support for hot loop shorting.
  6. *
  7. * @private
  8. * @param {Function} func The function to modify.
  9. * @param {Function} string The `toString` result.
  10. * @returns {Function} Returns `func`.
  11. */
  12. var baseSetToString = !defineProperty ? identity : function(func, string) {
  13. return defineProperty(func, 'toString', {
  14. 'configurable': true,
  15. 'enumerable': false,
  16. 'value': constant(string),
  17. 'writable': true
  18. });
  19. };
  20. module.exports = baseSetToString;