source: frontend/node_modules/es-abstract/2024/CharacterComplement.js

Last change on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 12 days ago

Fix frontend appearance

  • Property mode set to 100644
File size: 885 bytes
Line 
1'use strict';
2
3var $TypeError = require('es-errors/type');
4
5var AllCharacters = require('./AllCharacters');
6
7var CharSet = require('../helpers/CharSet').CharSet;
8var isRegExpRecord = require('../helpers/records/regexp-record');
9
10// https://262.ecma-international.org/15.0/#sec-charactercomplement
11
12module.exports = function CharacterComplement(rer, S) {
13 if (!isRegExpRecord(rer)) {
14 throw new $TypeError('Assertion failed: `rer` must be a RegExp Record');
15 }
16
17 if (!(S instanceof CharSet)) {
18 throw new $TypeError('Assertion failed: S must be a CharSet');
19 }
20
21 var A = AllCharacters(rer); // step 1
22
23 // 2. Return the CharSet containing the CharSetElements of A which are not also CharSetElements of S.
24 return new CharSet(
25 function (x) { return !S.test(x) && A.test(x); },
26 function (emit) {
27 A.yield(function (x) {
28 if (!S.test(x)) {
29 emit(x);
30 }
31 });
32 }
33 );
34};
Note: See TracBrowser for help on using the repository browser.