areDiscriminatorValuesEqual.js 412 B

12345678910111213141516
  1. 'use strict';
  2. const isBsonType = require('../isBsonType');
  3. module.exports = function areDiscriminatorValuesEqual(a, b) {
  4. if (typeof a === 'string' && typeof b === 'string') {
  5. return a === b;
  6. }
  7. if (typeof a === 'number' && typeof b === 'number') {
  8. return a === b;
  9. }
  10. if (isBsonType(a, 'ObjectID') && isBsonType(b, 'ObjectID')) {
  11. return a.toString() === b.toString();
  12. }
  13. return false;
  14. };