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.

string-prototype-umd.js 6.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  1. (function (factory) {
  2. typeof define === 'function' && define.amd ? define(factory) :
  3. factory();
  4. }((function () { 'use strict';
  5. /* eslint-disable node/no-unsupported-features/es-syntax */
  6. /**
  7. * @param {RegExp} regex
  8. * @param {string} newFlags
  9. * @param {Integer} [newLastIndex=regex.lastIndex]
  10. * @returns {RegExp}
  11. */
  12. function mixinRegex(regex, newFlags) {
  13. var newLastIndex = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : regex.lastIndex;
  14. newFlags = newFlags || '';
  15. regex = new RegExp(regex.source, (newFlags.includes('g') ? 'g' : regex.global ? 'g' : '') + (newFlags.includes('i') ? 'i' : regex.ignoreCase ? 'i' : '') + (newFlags.includes('m') ? 'm' : regex.multiline ? 'm' : '') + (newFlags.includes('u') ? 'u' : regex.unicode ? 'u' : '') + (newFlags.includes('y') ? 'y' : regex.sticky ? 'y' : '') + (newFlags.includes('s') ? 's' : regex.dotAll ? 's' : ''));
  16. regex.lastIndex = newLastIndex;
  17. return regex;
  18. }
  19. // We copy the regular expression so as to be able to always ensure the exec
  20. String.prototype.forEach = function (regex, cb) {
  21. var thisObj = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  22. var matches,
  23. n0,
  24. i = 0;
  25. regex = mixinRegex(regex, 'g');
  26. while ((matches = regex.exec(this)) !== null) {
  27. n0 = matches.splice(0, 1);
  28. cb.apply(thisObj, matches.concat(i++, n0));
  29. }
  30. return this;
  31. };
  32. String.prototype.some = function (regex, cb) {
  33. var thisObj = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  34. var matches,
  35. ret,
  36. n0,
  37. i = 0;
  38. regex = mixinRegex(regex, 'g');
  39. while ((matches = regex.exec(this)) !== null) {
  40. n0 = matches.splice(0, 1);
  41. ret = cb.apply(thisObj, matches.concat(i++, n0));
  42. if (ret) {
  43. return true;
  44. }
  45. }
  46. return false;
  47. };
  48. String.prototype.every = function (regex, cb) {
  49. var thisObj = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  50. var matches,
  51. ret,
  52. n0,
  53. i = 0;
  54. regex = mixinRegex(regex, 'g');
  55. while ((matches = regex.exec(this)) !== null) {
  56. n0 = matches.splice(0, 1);
  57. ret = cb.apply(thisObj, matches.concat(i++, n0));
  58. if (!ret) {
  59. return false;
  60. }
  61. }
  62. return true;
  63. };
  64. String.prototype.map = function (regex, cb) {
  65. var thisObj = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  66. var matches,
  67. n0,
  68. i = 0;
  69. var ret = [];
  70. regex = mixinRegex(regex, 'g');
  71. while ((matches = regex.exec(this)) !== null) {
  72. n0 = matches.splice(0, 1);
  73. ret.push(cb.apply(thisObj, matches.concat(i++, n0)));
  74. }
  75. return ret;
  76. };
  77. String.prototype.filter = function (regex, cb) {
  78. var thisObj = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  79. var matches,
  80. n0,
  81. i = 0;
  82. var ret = [];
  83. regex = mixinRegex(regex, 'g');
  84. while ((matches = regex.exec(this)) !== null) {
  85. n0 = matches.splice(0, 1);
  86. matches = matches.concat(i++, n0);
  87. if (cb.apply(thisObj, matches)) {
  88. ret.push(n0[0]);
  89. }
  90. }
  91. return ret;
  92. };
  93. String.prototype.reduce = function (regex, cb, prev) {
  94. var thisObj = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
  95. var matches,
  96. n0,
  97. i = 0;
  98. regex = mixinRegex(regex, 'g');
  99. if (!prev) {
  100. if ((matches = regex.exec(this)) !== null) {
  101. n0 = matches.splice(0, 1);
  102. prev = cb.apply(thisObj, [''].concat(matches.concat(i++, n0)));
  103. }
  104. }
  105. while ((matches = regex.exec(this)) !== null) {
  106. n0 = matches.splice(0, 1);
  107. prev = cb.apply(thisObj, [prev].concat(matches.concat(i++, n0)));
  108. }
  109. return prev;
  110. };
  111. String.prototype.reduceRight = function (regex, cb, prevOrig, thisObjOrig) {
  112. var matches,
  113. n0,
  114. i,
  115. prev = prevOrig,
  116. thisObj = thisObjOrig;
  117. var matchesContainer = [];
  118. regex = mixinRegex(regex, 'g');
  119. thisObj = thisObj || null;
  120. while ((matches = regex.exec(this)) !== null) {
  121. matchesContainer.push(matches);
  122. }
  123. i = matchesContainer.length;
  124. if (!i) {
  125. if (arguments.length < 3) {
  126. throw new TypeError('reduce of empty matches array with no initial value');
  127. }
  128. return prev;
  129. }
  130. if (!prev) {
  131. matches = matchesContainer.splice(-1)[0];
  132. n0 = matches.splice(0, 1);
  133. prev = cb.apply(thisObj, [''].concat(matches.concat(i--, n0)));
  134. }
  135. matchesContainer.reduceRight(function (container, mtches) {
  136. n0 = mtches.splice(0, 1);
  137. prev = cb.apply(thisObj, [prev].concat(mtches.concat(i--, n0)));
  138. return container;
  139. }, matchesContainer);
  140. return prev;
  141. };
  142. String.prototype.find = function (regex, cb) {
  143. var thisObj = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  144. var matches,
  145. ret,
  146. n0,
  147. i = 0;
  148. regex = mixinRegex(regex, 'g');
  149. while ((matches = regex.exec(this)) !== null) {
  150. n0 = matches.splice(0, 1);
  151. ret = cb.apply(thisObj, matches.concat(i++, n0));
  152. if (ret) {
  153. return n0[0];
  154. }
  155. }
  156. return false;
  157. };
  158. String.prototype.findIndex = function (regex, cb) {
  159. var thisObj = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  160. var matches,
  161. ret,
  162. n0,
  163. i = 0;
  164. regex = mixinRegex(regex, 'g');
  165. while ((matches = regex.exec(this)) !== null) {
  166. n0 = matches.splice(0, 1);
  167. ret = cb.apply(thisObj, matches.concat(i++, n0));
  168. if (ret) {
  169. return i - 1;
  170. }
  171. }
  172. return -1;
  173. };
  174. String.prototype.findExec = function (regex, cb) {
  175. var thisObj = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  176. var matches,
  177. ret,
  178. n0,
  179. i = 0;
  180. regex = mixinRegex(regex, 'g');
  181. while ((matches = regex.exec(this)) !== null) {
  182. n0 = matches.splice(0, 1);
  183. ret = cb.apply(thisObj, matches.concat(i++, n0));
  184. if (ret) {
  185. return matches;
  186. }
  187. }
  188. return false;
  189. };
  190. String.prototype.filterExec = function (regex, cb) {
  191. var thisObj = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  192. var matches,
  193. n0,
  194. i = 0;
  195. var ret = [];
  196. regex = mixinRegex(regex, 'g');
  197. while ((matches = regex.exec(this)) !== null) {
  198. n0 = matches.splice(0, 1);
  199. matches.push(i++, n0[0]);
  200. if (cb.apply(thisObj, matches)) {
  201. ret.push(matches);
  202. }
  203. }
  204. return ret;
  205. };
  206. })));