min.transform.js 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import { factory } from '../../utils/factory.js';
  2. import { errorTransform } from './utils/errorTransform.js';
  3. import { createMin } from '../../function/statistics/min.js';
  4. import { lastDimToZeroBase } from './utils/lastDimToZeroBase.js';
  5. var name = 'min';
  6. var dependencies = ['typed', 'config', 'numeric', 'smaller'];
  7. export var createMinTransform = /* #__PURE__ */factory(name, dependencies, _ref => {
  8. var {
  9. typed,
  10. config,
  11. numeric,
  12. smaller
  13. } = _ref;
  14. var min = createMin({
  15. typed,
  16. config,
  17. numeric,
  18. smaller
  19. });
  20. /**
  21. * Attach a transform function to math.min
  22. * Adds a property transform containing the transform function.
  23. *
  24. * This transform changed the last `dim` parameter of function min
  25. * from one-based to zero based
  26. */
  27. return typed('min', {
  28. '...any': function any(args) {
  29. args = lastDimToZeroBase(args);
  30. try {
  31. return min.apply(null, args);
  32. } catch (err) {
  33. throw errorTransform(err);
  34. }
  35. }
  36. });
  37. }, {
  38. isTransformFunction: true
  39. });