match-record.js 560 B

123456789101112131415161718
  1. 'use strict';
  2. var hasOwn = require('hasown');
  3. // https://262.ecma-international.org/13.0/#sec-match-records
  4. module.exports = function isMatchRecord(record) {
  5. return (
  6. !!record
  7. && typeof record === 'object'
  8. && hasOwn(record, '[[StartIndex]]')
  9. && hasOwn(record, '[[EndIndex]]')
  10. && record['[[StartIndex]]'] >= 0
  11. && record['[[EndIndex]]'] >= record['[[StartIndex]]']
  12. && String(parseInt(record['[[StartIndex]]'], 10)) === String(record['[[StartIndex]]'])
  13. && String(parseInt(record['[[EndIndex]]'], 10)) === String(record['[[EndIndex]]'])
  14. );
  15. };