areDiscriminatorValuesEqual.js 408 B

12345678910111213141516
  1. 'use strict';
  2. const ObjectId = require('../../types/objectid');
  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 (a instanceof ObjectId && b instanceof ObjectId) {
  11. return a.toString() === b.toString();
  12. }
  13. return false;
  14. };