1 | 'use strict'
|
2 |
|
3 | const errorTransform = require('./error.transform').transform
|
4 | const isCollection = require('../../utils/collection/isCollection')
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 | function factory (type, config, load, typed) {
|
14 | const min = load(require('../../function/statistics/min'))
|
15 |
|
16 | return typed('min', {
|
17 | '...any': function (args) {
|
18 |
|
19 | if (args.length === 2 && isCollection(args[0])) {
|
20 | const dim = args[1]
|
21 | if (type.isNumber(dim)) {
|
22 | args[1] = dim - 1
|
23 | } else if (type.isBigNumber(dim)) {
|
24 | args[1] = dim.minus(1)
|
25 | }
|
26 | }
|
27 |
|
28 | try {
|
29 | return min.apply(null, args)
|
30 | } catch (err) {
|
31 | throw errorTransform(err)
|
32 | }
|
33 | }
|
34 | })
|
35 | }
|
36 |
|
37 | exports.name = 'min'
|
38 | exports.path = 'expression.transform'
|
39 | exports.factory = factory
|