implementation.js 801 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. 'use strict';
  2. var functionsHaveConfigurableNames = require('functions-have-names').functionsHaveConfigurableNames();
  3. var $Object = Object;
  4. var $TypeError = TypeError;
  5. module.exports = function flags() {
  6. if (this != null && this !== $Object(this)) {
  7. throw new $TypeError('RegExp.prototype.flags getter called on non-object');
  8. }
  9. var result = '';
  10. if (this.hasIndices) {
  11. result += 'd';
  12. }
  13. if (this.global) {
  14. result += 'g';
  15. }
  16. if (this.ignoreCase) {
  17. result += 'i';
  18. }
  19. if (this.multiline) {
  20. result += 'm';
  21. }
  22. if (this.dotAll) {
  23. result += 's';
  24. }
  25. if (this.unicode) {
  26. result += 'u';
  27. }
  28. if (this.sticky) {
  29. result += 'y';
  30. }
  31. return result;
  32. };
  33. if (functionsHaveConfigurableNames && Object.defineProperty) {
  34. Object.defineProperty(module.exports, 'name', { value: 'get flags' });
  35. }