You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

IsRegExp.js 547B

123456789101112131415161718192021222324
  1. 'use strict';
  2. var GetIntrinsic = require('../GetIntrinsic');
  3. var $match = GetIntrinsic('%Symbol.match%', true);
  4. var hasRegExpMatcher = require('is-regex');
  5. var ToBoolean = require('./ToBoolean');
  6. // https://ecma-international.org/ecma-262/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. };