source: frontend/node_modules/es-abstract/2024/IsWordChar.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: 1.1 KB
Line 
1'use strict';
2
3var $TypeError = require('es-errors/type');
4var callBound = require('call-bound');
5var isInteger = require('math-intrinsics/isInteger');
6
7var $indexOf = callBound('String.prototype.indexOf');
8
9var IsArray = require('./IsArray');
10var WordCharacters = require('./WordCharacters');
11
12var every = require('../helpers/every');
13var isRegExpRecord = require('../helpers/records/regexp-record');
14
15var isChar = function isChar(c) {
16 return typeof c === 'string';
17};
18
19// https://262.ecma-international.org/14.0/#sec-runtime-semantics-iswordchar-abstract-operation
20
21module.exports = function IsWordChar(rer, Input, e) {
22 if (!isRegExpRecord(rer)) {
23 throw new $TypeError('Assertion failed: `rer` must be a RegExp Record');
24 }
25 if (!IsArray(Input) || !every(Input, isChar)) {
26 throw new $TypeError('Assertion failed: `Input` must be a List of characters');
27 }
28
29 if (!isInteger(e)) {
30 throw new $TypeError('Assertion failed: `e` must be an integer');
31 }
32
33 var InputLength = Input.length; // step 1
34
35 if (e === -1 || e === InputLength) {
36 return false; // step 2
37 }
38
39 var c = Input[e]; // step 3
40
41 return $indexOf(WordCharacters(rer), c) > -1; // steps 4-5
42};
Note: See TracBrowser for help on using the repository browser.