main
Last change
on this file since d565449 was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago |
Update repo after prototype presentation
|
-
Property mode
set to
100644
|
File size:
387 bytes
|
Line | |
---|
1 | 'use strict';
|
---|
2 |
|
---|
3 | var callBound = require('call-bind/callBound');
|
---|
4 | var isRegex = require('is-regex');
|
---|
5 |
|
---|
6 | var $exec = callBound('RegExp.prototype.exec');
|
---|
7 | var $TypeError = require('es-errors/type');
|
---|
8 |
|
---|
9 | module.exports = function regexTester(regex) {
|
---|
10 | if (!isRegex(regex)) {
|
---|
11 | throw new $TypeError('`regex` must be a RegExp');
|
---|
12 | }
|
---|
13 | return function test(s) {
|
---|
14 | return $exec(regex, s) !== null;
|
---|
15 | };
|
---|
16 | };
|
---|
Note:
See
TracBrowser
for help on using the repository browser.