correct-is-regexp-logic.js 366 B

123456789101112131415
  1. var wellKnownSymbol = require('../internals/well-known-symbol');
  2. var MATCH = wellKnownSymbol('match');
  3. module.exports = function (METHOD_NAME) {
  4. var regexp = /./;
  5. try {
  6. '/./'[METHOD_NAME](regexp);
  7. } catch (error1) {
  8. try {
  9. regexp[MATCH] = false;
  10. return '/./'[METHOD_NAME](regexp);
  11. } catch (error2) { /* empty */ }
  12. } return false;
  13. };