regexp-flags.js 562 B

123456789101112131415161718
  1. 'use strict';
  2. var anObject = require('../internals/an-object');
  3. // `RegExp.prototype.flags` getter implementation
  4. // https://tc39.es/ecma262/#sec-get-regexp.prototype.flags
  5. module.exports = function () {
  6. var that = anObject(this);
  7. var result = '';
  8. if (that.hasIndices) result += 'd';
  9. if (that.global) result += 'g';
  10. if (that.ignoreCase) result += 'i';
  11. if (that.multiline) result += 'm';
  12. if (that.dotAll) result += 's';
  13. if (that.unicode) result += 'u';
  14. if (that.unicodeSets) result += 'v';
  15. if (that.sticky) result += 'y';
  16. return result;
  17. };