compareUnits.js 441 B

1234567891011121314
  1. import { factory } from '../../utils/factory.js';
  2. export var createCompareUnits = /* #__PURE__ */factory('compareUnits', ['typed'], _ref => {
  3. var {
  4. typed
  5. } = _ref;
  6. return {
  7. 'Unit, Unit': typed.referToSelf(self => (x, y) => {
  8. if (!x.equalBase(y)) {
  9. throw new Error('Cannot compare units with different base');
  10. }
  11. return typed.find(self, [x.valueType(), y.valueType()])(x.value, y.value);
  12. })
  13. };
  14. });