Node-Red configuration
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.

es.regexp.to-string.js 1.1KB

1234567891011121314151617181920212223242526
  1. 'use strict';
  2. var PROPER_FUNCTION_NAME = require('../internals/function-name').PROPER;
  3. var defineBuiltIn = require('../internals/define-built-in');
  4. var anObject = require('../internals/an-object');
  5. var $toString = require('../internals/to-string');
  6. var fails = require('../internals/fails');
  7. var getRegExpFlags = require('../internals/regexp-get-flags');
  8. var TO_STRING = 'toString';
  9. var RegExpPrototype = RegExp.prototype;
  10. var nativeToString = RegExpPrototype[TO_STRING];
  11. var NOT_GENERIC = fails(function () { return nativeToString.call({ source: 'a', flags: 'b' }) !== '/a/b'; });
  12. // FF44- RegExp#toString has a wrong name
  13. var INCORRECT_NAME = PROPER_FUNCTION_NAME && nativeToString.name !== TO_STRING;
  14. // `RegExp.prototype.toString` method
  15. // https://tc39.es/ecma262/#sec-regexp.prototype.tostring
  16. if (NOT_GENERIC || INCORRECT_NAME) {
  17. defineBuiltIn(RegExpPrototype, TO_STRING, function toString() {
  18. var R = anObject(this);
  19. var pattern = $toString(R.source);
  20. var flags = $toString(getRegExpFlags(R));
  21. return '/' + pattern + '/' + flags;
  22. }, { unsafe: true });
  23. }