max.transform.js 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.createMaxTransform = void 0;
  6. var _factory = require("../../utils/factory.js");
  7. var _errorTransform = require("./utils/errorTransform.js");
  8. var _max = require("../../function/statistics/max.js");
  9. var _lastDimToZeroBase = require("./utils/lastDimToZeroBase.js");
  10. var name = 'max';
  11. var dependencies = ['typed', 'config', 'numeric', 'larger'];
  12. var createMaxTransform = /* #__PURE__ */(0, _factory.factory)(name, dependencies, function (_ref) {
  13. var typed = _ref.typed,
  14. config = _ref.config,
  15. numeric = _ref.numeric,
  16. larger = _ref.larger;
  17. var max = (0, _max.createMax)({
  18. typed: typed,
  19. config: config,
  20. numeric: numeric,
  21. larger: larger
  22. });
  23. /**
  24. * Attach a transform function to math.max
  25. * Adds a property transform containing the transform function.
  26. *
  27. * This transform changed the last `dim` parameter of function max
  28. * from one-based to zero based
  29. */
  30. return typed('max', {
  31. '...any': function any(args) {
  32. args = (0, _lastDimToZeroBase.lastDimToZeroBase)(args);
  33. try {
  34. return max.apply(null, args);
  35. } catch (err) {
  36. throw (0, _errorTransform.errorTransform)(err);
  37. }
  38. }
  39. });
  40. }, {
  41. isTransformFunction: true
  42. });
  43. exports.createMaxTransform = createMaxTransform;