polyfill.js 458 B

123456789101112131415
  1. 'use strict';
  2. var implementation = require('./implementation');
  3. module.exports = function getPolyfill() {
  4. if (!String.prototype.trimEnd && !String.prototype.trimRight) {
  5. return implementation;
  6. }
  7. var zeroWidthSpace = '\u200b';
  8. var trimmed = zeroWidthSpace.trimEnd ? zeroWidthSpace.trimEnd() : zeroWidthSpace.trimRight();
  9. if (trimmed !== zeroWidthSpace) {
  10. return implementation;
  11. }
  12. return String.prototype.trimEnd || String.prototype.trimRight;
  13. };