source: imaps-frontend/node_modules/safe-regex-test/index.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: 387 bytes
RevLine 
[d565449]1'use strict';
2
3var callBound = require('call-bind/callBound');
4var isRegex = require('is-regex');
5
6var $exec = callBound('RegExp.prototype.exec');
7var $TypeError = require('es-errors/type');
8
9module.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.