Software zum Installieren eines Smart-Mirror Frameworks , zum Nutzen von hochschulrelevanten Informationen, auf einem Raspberry-Pi.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

fix-regexp-well-known-symbol-logic.js 2.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. 'use strict';
  2. // TODO: Remove from `core-js@4` since it's moved to entry points
  3. require('../modules/es.regexp.exec');
  4. var redefine = require('../internals/redefine');
  5. var regexpExec = require('../internals/regexp-exec');
  6. var fails = require('../internals/fails');
  7. var wellKnownSymbol = require('../internals/well-known-symbol');
  8. var createNonEnumerableProperty = require('../internals/create-non-enumerable-property');
  9. var SPECIES = wellKnownSymbol('species');
  10. var RegExpPrototype = RegExp.prototype;
  11. module.exports = function (KEY, exec, FORCED, SHAM) {
  12. var SYMBOL = wellKnownSymbol(KEY);
  13. var DELEGATES_TO_SYMBOL = !fails(function () {
  14. // String methods call symbol-named RegEp methods
  15. var O = {};
  16. O[SYMBOL] = function () { return 7; };
  17. return ''[KEY](O) != 7;
  18. });
  19. var DELEGATES_TO_EXEC = DELEGATES_TO_SYMBOL && !fails(function () {
  20. // Symbol-named RegExp methods call .exec
  21. var execCalled = false;
  22. var re = /a/;
  23. if (KEY === 'split') {
  24. // We can't use real regex here since it causes deoptimization
  25. // and serious performance degradation in V8
  26. // https://github.com/zloirock/core-js/issues/306
  27. re = {};
  28. // RegExp[@@split] doesn't call the regex's exec method, but first creates
  29. // a new one. We need to return the patched regex when creating the new one.
  30. re.constructor = {};
  31. re.constructor[SPECIES] = function () { return re; };
  32. re.flags = '';
  33. re[SYMBOL] = /./[SYMBOL];
  34. }
  35. re.exec = function () { execCalled = true; return null; };
  36. re[SYMBOL]('');
  37. return !execCalled;
  38. });
  39. if (
  40. !DELEGATES_TO_SYMBOL ||
  41. !DELEGATES_TO_EXEC ||
  42. FORCED
  43. ) {
  44. var nativeRegExpMethod = /./[SYMBOL];
  45. var methods = exec(SYMBOL, ''[KEY], function (nativeMethod, regexp, str, arg2, forceStringMethod) {
  46. var $exec = regexp.exec;
  47. if ($exec === regexpExec || $exec === RegExpPrototype.exec) {
  48. if (DELEGATES_TO_SYMBOL && !forceStringMethod) {
  49. // The native String method already delegates to @@method (this
  50. // polyfilled function), leasing to infinite recursion.
  51. // We avoid it by directly calling the native @@method method.
  52. return { done: true, value: nativeRegExpMethod.call(regexp, str, arg2) };
  53. }
  54. return { done: true, value: nativeMethod.call(str, regexp, arg2) };
  55. }
  56. return { done: false };
  57. });
  58. redefine(String.prototype, KEY, methods[0]);
  59. redefine(RegExpPrototype, SYMBOL, methods[1]);
  60. }
  61. if (SHAM) createNonEnumerableProperty(RegExpPrototype[SYMBOL], 'sham', true);
  62. };