regexp-record.js 850 B

1234567891011121314151617181920212223
  1. 'use strict';
  2. var hasOwn = require('hasown');
  3. var isInteger = require('../isInteger');
  4. module.exports = function isRegExpRecord(value) {
  5. return !!value
  6. && typeof value === 'object'
  7. && hasOwn(value, '[[IgnoreCase]]')
  8. && typeof value['[[IgnoreCase]]'] === 'boolean'
  9. && hasOwn(value, '[[Multiline]]')
  10. && typeof value['[[Multiline]]'] === 'boolean'
  11. && hasOwn(value, '[[DotAll]]')
  12. && typeof value['[[DotAll]]'] === 'boolean'
  13. && hasOwn(value, '[[Unicode]]')
  14. && typeof value['[[Unicode]]'] === 'boolean'
  15. && hasOwn(value, '[[CapturingGroupsCount]]')
  16. && typeof value['[[CapturingGroupsCount]]'] === 'number'
  17. && isInteger(value['[[CapturingGroupsCount]]'])
  18. && value['[[CapturingGroupsCount]]'] >= 0
  19. && (!hasOwn(value, '[[UnicodeSets]]') || typeof value['[[UnicodeSets]]'] === 'boolean'); // optional since it was added later
  20. };