source: imaps-frontend/node_modules/es-abstract/2018/RegExpExec.js

main
Last change on this file was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago

Update repo after prototype presentation

  • Property mode set to 100644
File size: 817 bytes
RevLine 
[d565449]1'use strict';
2
3var $TypeError = require('es-errors/type');
4
5var regexExec = require('call-bind/callBound')('RegExp.prototype.exec');
6
7var Call = require('./Call');
8var Get = require('./Get');
9var IsCallable = require('./IsCallable');
10var Type = require('./Type');
11
12// https://262.ecma-international.org/6.0/#sec-regexpexec
13
14module.exports = function RegExpExec(R, S) {
15 if (Type(R) !== 'Object') {
16 throw new $TypeError('Assertion failed: `R` must be an Object');
17 }
18 if (typeof S !== 'string') {
19 throw new $TypeError('Assertion failed: `S` must be a String');
20 }
21 var exec = Get(R, 'exec');
22 if (IsCallable(exec)) {
23 var result = Call(exec, R, [S]);
24 if (typeof result === 'object') {
25 return result;
26 }
27 throw new $TypeError('"exec" method must return `null` or an Object');
28 }
29 return regexExec(R, S);
30};
Note: See TracBrowser for help on using the repository browser.