UNPKG

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