HasEitherUnicodeFlag.js 517 B

123456789101112131415161718
  1. 'use strict';
  2. var $TypeError = require('es-errors/type');
  3. var isRegExpRecord = require('../helpers/records/regexp-record');
  4. // https://262.ecma-international.org/15.0/#sec-runtime-semantics-haseitherunicodeflag-abstract-operation
  5. module.exports = function HasEitherUnicodeFlag(rer) {
  6. if (!isRegExpRecord(rer)) {
  7. throw new $TypeError('Assertion failed: `rer` must be a RegExp Record');
  8. }
  9. if (rer['[[Unicode]]'] || rer['[[UnicodeSets]]']) { // step 1
  10. return true; // step 1.a
  11. }
  12. return false; // step 2
  13. };