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