IsRegExp.js 540 B

123456789101112131415161718192021222324
  1. 'use strict';
  2. var GetIntrinsic = require('get-intrinsic');
  3. var $match = GetIntrinsic('%Symbol.match%', true);
  4. var hasRegExpMatcher = require('is-regex');
  5. var ToBoolean = require('./ToBoolean');
  6. // https://262.ecma-international.org/6.0/#sec-isregexp
  7. module.exports = function IsRegExp(argument) {
  8. if (!argument || typeof argument !== 'object') {
  9. return false;
  10. }
  11. if ($match) {
  12. var isRegExp = argument[$match];
  13. if (typeof isRegExp !== 'undefined') {
  14. return ToBoolean(isRegExp);
  15. }
  16. }
  17. return hasRegExpMatcher(argument);
  18. };