implementation.js 710 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. 'use strict';
  2. var setFunctionName = require('set-function-name');
  3. var $TypeError = require('es-errors/type');
  4. var $Object = Object;
  5. module.exports = setFunctionName(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.unicodeSets) {
  29. result += 'v';
  30. }
  31. if (this.sticky) {
  32. result += 'y';
  33. }
  34. return result;
  35. }, 'get flags', true);