AllCharacters.js 1.1 KB

1234567891011121314151617181920212223242526272829
  1. 'use strict';
  2. var $TypeError = require('es-errors/type');
  3. var HasEitherUnicodeFlag = require('./HasEitherUnicodeFlag');
  4. var isRegExpRecord = require('../helpers/records/regexp-record');
  5. var CharSet = require('../helpers/CharSet');
  6. // https://262.ecma-international.org/15.0/#sec-allcharacters
  7. module.exports = function AllCharacters(rer) {
  8. if (!isRegExpRecord(rer)) {
  9. throw new $TypeError('Assertion failed: `rer` must be a RegExp Record');
  10. }
  11. if (rer['[[UnicodeSets]]'] && rer['[[IgnoreCase]]']) { // step 1
  12. // 1. Return the CharSet containing all Unicode code points _c_ that do not have a <a href="https://www.unicode.org/reports/tr44/#Simple_Case_Folding">Simple Case Folding</a> mapping (that is, scf(_c_)=_c_).
  13. return CharSet.getNonSimpleCaseFoldingCodePoints(); // step 1.a
  14. } else if (HasEitherUnicodeFlag(rer)) { // step 2
  15. // 1. Return the CharSet containing all code point values.
  16. return CharSet.getCodePoints(); // step 3.a
  17. // eslint-disable-next-line no-else-return
  18. } else { // step 3
  19. // 1. Return the CharSet containing all code unit values.
  20. return CharSet.getCodeUnits(); // step 3.a
  21. }
  22. };