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.

prototype.js 3.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. /* eslint-disable no-extend-native,
  2. no-use-extend-native/no-use-extend-native,
  3. node/no-unsupported-features/es-syntax */
  4. // We copy the regular expression so as to be able to always ensure the
  5. // exec expression is a global one (and thereby prevent recursion)
  6. import mixinRegex from './mixinRegex.js';
  7. RegExp.prototype.forEach = function (str, cb, thisObj = null) {
  8. let matches, n0, i = 0;
  9. const regex = mixinRegex(this, 'g');
  10. while ((matches = regex.exec(str)) !== null) {
  11. n0 = matches.splice(0, 1);
  12. cb.apply(thisObj, matches.concat(i++, n0));
  13. }
  14. return this;
  15. };
  16. RegExp.prototype.some = function (str, cb, thisObj = null) {
  17. let matches, ret, n0, i = 0;
  18. const regex = mixinRegex(this, 'g');
  19. while ((matches = regex.exec(str)) !== null) {
  20. n0 = matches.splice(0, 1);
  21. ret = cb.apply(thisObj, matches.concat(i++, n0));
  22. if (ret) {
  23. return true;
  24. }
  25. }
  26. return false;
  27. };
  28. RegExp.prototype.every = function (str, cb, thisObj = null) {
  29. let matches, ret, n0, i = 0;
  30. const regex = mixinRegex(this, 'g');
  31. while ((matches = regex.exec(str)) !== null) {
  32. n0 = matches.splice(0, 1);
  33. ret = cb.apply(thisObj, matches.concat(i++, n0));
  34. if (!ret) {
  35. return false;
  36. }
  37. }
  38. return true;
  39. };
  40. RegExp.prototype.map = function (str, cb, thisObj = null) {
  41. let matches, n0, i = 0;
  42. const ret = [];
  43. const regex = mixinRegex(this, 'g');
  44. while ((matches = regex.exec(str)) !== null) {
  45. n0 = matches.splice(0, 1);
  46. ret.push(cb.apply(thisObj, matches.concat(i++, n0)));
  47. }
  48. return ret;
  49. };
  50. RegExp.prototype.filter = function (str, cb, thisObj = null) {
  51. let matches, n0, i = 0;
  52. const ret = [];
  53. const regex = mixinRegex(this, 'g');
  54. while ((matches = regex.exec(str)) !== null) {
  55. n0 = matches.splice(0, 1);
  56. matches = matches.concat(i++, n0);
  57. if (cb.apply(thisObj, matches)) {
  58. ret.push(matches[0]);
  59. }
  60. }
  61. return ret;
  62. };
  63. RegExp.prototype.reduce = function (str, cb, prev, thisObj = null) {
  64. let matches, n0, i = 0;
  65. const regex = mixinRegex(this, 'g');
  66. if (!prev) {
  67. if ((matches = regex.exec(str)) !== null) {
  68. n0 = matches.splice(0, 1);
  69. prev = cb.apply(thisObj, [''].concat(matches.concat(n0, i++)));
  70. }
  71. }
  72. while ((matches = regex.exec(str)) !== null) {
  73. n0 = matches.splice(0, 1);
  74. prev = cb.apply(thisObj, [prev].concat(matches.concat(n0, i++)));
  75. }
  76. return prev;
  77. };
  78. RegExp.prototype.reduceRight = function (str, cb, prevOrig, thisObjOrig) {
  79. let matches, n0, i,
  80. prev = prevOrig, thisObj = thisObjOrig;
  81. const regex = mixinRegex(this, 'g');
  82. const matchesContainer = [];
  83. thisObj = thisObj || null;
  84. while ((matches = regex.exec(str)) !== null) {
  85. matchesContainer.push(matches);
  86. }
  87. i = matchesContainer.length;
  88. if (!i) {
  89. if (arguments.length < 3) {
  90. throw new TypeError(
  91. 'reduce of empty matches array with no initial value'
  92. );
  93. }
  94. return prev;
  95. }
  96. if (!prev) {
  97. matches = matchesContainer.splice(-1)[0];
  98. n0 = matches.splice(0, 1);
  99. prev = cb.apply(thisObj, [''].concat(matches.concat(n0, i--)));
  100. }
  101. matchesContainer.reduceRight(function (container, mtches) {
  102. n0 = mtches.splice(0, 1);
  103. prev = cb.apply(thisObj, [prev].concat(mtches.concat(n0, i--)));
  104. return container;
  105. }, matchesContainer);
  106. return prev;
  107. };