(args, math, scope)
| 18 | const transformCallback = createTransformCallback({ typed }) |
| 19 | |
| 20 | function mapTransform (args, math, scope) { |
| 21 | if (args.length === 0) { |
| 22 | return map() |
| 23 | } |
| 24 | |
| 25 | if (args.length === 1) { |
| 26 | return map(args[0]) |
| 27 | } |
| 28 | const N = args.length - 1 |
| 29 | let X = args.slice(0, N) |
| 30 | let callback = args[N] |
| 31 | X = X.map(arg => _compileAndEvaluate(arg, scope)) |
| 32 | |
| 33 | if (callback) { |
| 34 | if (isSymbolNode(callback) || isFunctionAssignmentNode(callback)) { |
| 35 | // a function pointer, like filter([3, -2, 5], myTestFunction) |
| 36 | callback = _compileAndEvaluate(callback, scope) |
| 37 | } else { |
| 38 | // an expression like filter([3, -2, 5], x > 0) |
| 39 | callback = compileInlineExpression(callback, math, scope) |
| 40 | } |
| 41 | } |
| 42 | return map(...X, transformCallback(callback, N)) |
| 43 | |
| 44 | function _compileAndEvaluate (arg, scope) { |
| 45 | return arg.compile().evaluate(scope) |
| 46 | } |
| 47 | } |
| 48 | mapTransform.rawArgs = true |
| 49 | |
| 50 | return mapTransform |
nothing calls this directly
no test coverage detected
searching dependent graphs…