Skip to content

Commit

Permalink
[Robustness] use es-errors
Browse files Browse the repository at this point in the history
  • Loading branch information
ljharb committed Mar 20, 2024
1 parent 92e9c59 commit f6de643
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
3 changes: 2 additions & 1 deletion implementation.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ var callBound = require('call-bind/callBound');
var hasSymbols = require('has-symbols')();
var flagsGetter = require('regexp.prototype.flags');
var GetIntrinsic = require('get-intrinsic');
var $TypeError = require('es-errors/type');

var $RegExp = GetIntrinsic('%RegExp%');
var $indexOf = callBound('String.prototype.indexOf');
Expand Down Expand Up @@ -41,7 +42,7 @@ module.exports = function matchAll(regexp) {
var flags = 'flags' in regexp ? Get(regexp, 'flags') : flagsGetter(regexp);
RequireObjectCoercible(flags);
if ($indexOf(ToString(flags), 'g') < 0) {
throw new TypeError('matchAll requires a global regular expression');
throw new $TypeError('matchAll requires a global regular expression');
}
}

Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
"call-bind": "^1.0.2",
"define-properties": "^1.2.0",
"es-abstract": "^1.22.1",
"es-errors": "^1.3.0",
"es-object-atoms": "^1.0.0",
"get-intrinsic": "^1.2.1",
"gopd": "^1.0.1",
Expand Down
3 changes: 2 additions & 1 deletion regexp-matchall.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ var flagsGetter = require('regexp.prototype.flags');
var setFunctionName = require('set-function-name');
var callBound = require('call-bind/callBound');
var GetIntrinsic = require('get-intrinsic');
var $TypeError = require('es-errors/type');

var $indexOf = callBound('String.prototype.indexOf');

Expand All @@ -37,7 +38,7 @@ var constructRegexWithFlags = function constructRegex(C, R) {
var regexMatchAll = setFunctionName(function SymbolMatchAll(string) {
var R = this;
if (Type(R) !== 'Object') {
throw new TypeError('"this" value must be an Object');
throw new $TypeError('"this" value must be an Object');
}
var S = ToString(string);
var C = SpeciesConstructor(R, OrigRegExp);
Expand Down

0 comments on commit f6de643

Please sign in to comment.