compareUnits.js 664 B

123456789101112131415161718192021
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.createCompareUnits = void 0;
  6. var _factory = require("../../utils/factory.js");
  7. var createCompareUnits = /* #__PURE__ */(0, _factory.factory)('compareUnits', ['typed'], function (_ref) {
  8. var typed = _ref.typed;
  9. return {
  10. 'Unit, Unit': typed.referToSelf(function (self) {
  11. return function (x, y) {
  12. if (!x.equalBase(y)) {
  13. throw new Error('Cannot compare units with different base');
  14. }
  15. return typed.find(self, [x.valueType(), y.valueType()])(x.value, y.value);
  16. };
  17. })
  18. };
  19. });
  20. exports.createCompareUnits = createCompareUnits;