correct-is-regexp-logic.js 380 B

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