UNPKG

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