Ohm-Management - Projektarbeit B-ME
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.

index.js 698B

123456789101112131415161718192021222324252627
  1. const toString = Object.prototype.toString;
  2. function isRegExp (o) {
  3. return 'object' == typeof o
  4. && '[object RegExp]' == toString.call(o);
  5. }
  6. module.exports = exports = function (regexp) {
  7. if (!isRegExp(regexp)) {
  8. throw new TypeError('Not a RegExp');
  9. }
  10. const flags = [];
  11. if (regexp.global) flags.push('g');
  12. if (regexp.multiline) flags.push('m');
  13. if (regexp.ignoreCase) flags.push('i');
  14. if (regexp.dotAll) flags.push('s');
  15. if (regexp.unicode) flags.push('u');
  16. if (regexp.sticky) flags.push('y');
  17. const result = new RegExp(regexp.source, flags.join(''));
  18. if (typeof regexp.lastIndex === 'number') {
  19. result.lastIndex = regexp.lastIndex;
  20. }
  21. return result;
  22. }