UNPKG

1.02 kBJavaScriptView Raw
1'use strict';
2
3var errorTransform = require('./error.transform').transform;
4/**
5 * Attach a transform function to math.range
6 * Adds a property transform containing the transform function.
7 *
8 * This transform changed the last `dim` parameter of function concat
9 * from one-based to zero based
10 */
11
12
13function factory(type, config, load, typed) {
14 var concat = load(require('../../function/matrix/concat')); // @see: comment of concat itself
15
16 return typed('concat', {
17 '...any': function any(args) {
18 // change last argument from one-based to zero-based
19 var lastIndex = args.length - 1;
20 var last = args[lastIndex];
21
22 if (type.isNumber(last)) {
23 args[lastIndex] = last - 1;
24 } else if (type.isBigNumber(last)) {
25 args[lastIndex] = last.minus(1);
26 }
27
28 try {
29 return concat.apply(null, args);
30 } catch (err) {
31 throw errorTransform(err);
32 }
33 }
34 });
35}
36
37exports.name = 'concat';
38exports.path = 'expression.transform';
39exports.factory = factory;
\No newline at end of file