|
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 |
|
|---|
| 3 | var $TypeError = require('es-errors/type');
|
|---|
| 4 | var callBound = require('call-bound');
|
|---|
| 5 | var isInteger = require('math-intrinsics/isInteger');
|
|---|
| 6 |
|
|---|
| 7 | var $indexOf = callBound('String.prototype.indexOf');
|
|---|
| 8 |
|
|---|
| 9 | var IsArray = require('./IsArray');
|
|---|
| 10 | var WordCharacters = require('./WordCharacters');
|
|---|
| 11 |
|
|---|
| 12 | var every = require('../helpers/every');
|
|---|
| 13 | var isRegExpRecord = require('../helpers/records/regexp-record');
|
|---|
| 14 |
|
|---|
| 15 | var 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 | module.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.