UNPKG

1.27 kBJavaScriptView Raw
1import { isBigNumber, isNumber } from '../../utils/is.js';
2import { errorTransform } from './utils/errorTransform.js';
3import { factory } from '../../utils/factory.js';
4import { createConcat } from '../../function/matrix/concat.js';
5var name = 'concat';
6var dependencies = ['typed', 'matrix', 'isInteger'];
7export var createConcatTransform = /* #__PURE__ */factory(name, dependencies, _ref => {
8 var {
9 typed,
10 matrix,
11 isInteger
12 } = _ref;
13 var concat = createConcat({
14 typed,
15 matrix,
16 isInteger
17 });
18 /**
19 * Attach a transform function to math.range
20 * Adds a property transform containing the transform function.
21 *
22 * This transform changed the last `dim` parameter of function concat
23 * from one-based to zero based
24 */
25
26 return typed('concat', {
27 '...any': function any(args) {
28 // change last argument from one-based to zero-based
29 var lastIndex = args.length - 1;
30 var last = args[lastIndex];
31
32 if (isNumber(last)) {
33 args[lastIndex] = last - 1;
34 } else if (isBigNumber(last)) {
35 args[lastIndex] = last.minus(1);
36 }
37
38 try {
39 return concat.apply(null, args);
40 } catch (err) {
41 throw errorTransform(err);
42 }
43 }
44 });
45}, {
46 isTransformFunction: true
47});
\No newline at end of file