source: imaps-frontend/node_modules/es-abstract/2024/IsWordChar.js@ 79a0317

main
Last change on this file since 79a0317 was 79a0317, checked in by stefan toskovski <stefantoska84@…>, 3 days ago

F4 Finalna Verzija

  • Property mode set to 100644
File size: 1.2 KB
RevLine 
[d565449]1'use strict';
2
3var $TypeError = require('es-errors/type');
[79a0317]4var callBound = require('call-bound');
5var isInteger = require('math-intrinsics/isInteger');
[d565449]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
21// note: prior to ES2023, this AO erroneously omitted the latter of its arguments.
22module.exports = function IsWordChar(rer, Input, e) {
23 if (!isRegExpRecord(rer)) {
24 throw new $TypeError('Assertion failed: `rer` must be a RegExp Record');
25 }
26 if (!IsArray(Input) || !every(Input, isChar)) {
27 throw new $TypeError('Assertion failed: `Input` must be a List of characters');
28 }
29
30 if (!isInteger(e)) {
31 throw new $TypeError('Assertion failed: `e` must be an integer');
32 }
33
34 var InputLength = Input.length; // step 1
35
36 if (e === -1 || e === InputLength) {
37 return false; // step 2
38 }
39
40 var c = Input[e]; // step 3
41
42 return $indexOf(WordCharacters(rer), c) > -1; // steps 4-5
43};
Note: See TracBrowser for help on using the repository browser.