source: frontend/node_modules/es-abstract/2017/RegExpExec.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: 830 bytes
Line 
1'use strict';
2
3var $TypeError = require('es-errors/type');
4var isObject = require('es-object-atoms/isObject');
5var regexExec = require('call-bound')('RegExp.prototype.exec');
6
7var Call = require('./Call');
8var Get = require('./Get');
9var IsCallable = require('./IsCallable');
10
11// https://262.ecma-international.org/6.0/#sec-regexpexec
12
13module.exports = function RegExpExec(R, S) {
14 if (!isObject(R)) {
15 throw new $TypeError('Assertion failed: `R` must be an Object');
16 }
17 if (typeof S !== 'string') {
18 throw new $TypeError('Assertion failed: `S` must be a String');
19 }
20 var exec = Get(R, 'exec');
21 if (IsCallable(exec)) {
22 var result = Call(exec, R, [S]);
23 if (result === null || isObject(result)) {
24 return result;
25 }
26 throw new $TypeError('"exec" method must return `null` or an Object');
27 }
28 return regexExec(R, S);
29};
Note: See TracBrowser for help on using the repository browser.