RegExpCreate.js 643 B

123456789101112131415161718192021
  1. 'use strict';
  2. var GetIntrinsic = require('get-intrinsic');
  3. var $RegExp = GetIntrinsic('%RegExp%');
  4. // var RegExpAlloc = require('./RegExpAlloc');
  5. // var RegExpInitialize = require('./RegExpInitialize');
  6. var ToString = require('./ToString');
  7. // https://262.ecma-international.org/6.0/#sec-regexpcreate
  8. module.exports = function RegExpCreate(P, F) {
  9. // var obj = RegExpAlloc($RegExp);
  10. // return RegExpInitialize(obj, P, F);
  11. // covers spec mechanics; bypass regex brand checking
  12. var pattern = typeof P === 'undefined' ? '' : ToString(P);
  13. var flags = typeof F === 'undefined' ? '' : ToString(F);
  14. return new $RegExp(pattern, flags);
  15. };