correct-is-regexp-logic.js 356 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 (e) {
  8. try {
  9. regexp[MATCH] = false;
  10. return '/./'[METHOD_NAME](regexp);
  11. } catch (f) { /* empty */ }
  12. } return false;
  13. };