MCPcopy
hub / github.com/josdejong/mathjs / forEachTransform

Function forEachTransform

src/expression/transform/forEach.transform.js:19–47  ·  view source on GitHub ↗
(args, math, scope)

Source from the content-addressed store, hash-verified

17 const forEach = createForEach({ typed })
18 const transformCallback = createTransformCallback({ typed })
19 function forEachTransform (args, math, scope) {
20 if (args.length === 0) {
21 return forEach()
22 }
23 let x = args[0]
24
25 if (args.length === 1) {
26 return forEach(x)
27 }
28
29 const N = args.length - 1
30 let callback = args[N]
31
32 if (x) {
33 x = _compileAndEvaluate(x, scope)
34 }
35
36 if (callback) {
37 if (isSymbolNode(callback) || isFunctionAssignmentNode(callback)) {
38 // a function pointer, like filter([3, -2, 5], myTestFunction)
39 callback = _compileAndEvaluate(callback, scope)
40 } else {
41 // an expression like filter([3, -2, 5], x > 0)
42 callback = compileInlineExpression(callback, math, scope)
43 }
44 }
45
46 return forEach(x, transformCallback(callback, N))
47 }
48 forEachTransform.rawArgs = true
49
50 function _compileAndEvaluate (arg, scope) {

Callers

nothing calls this directly

Calls 5

isSymbolNodeFunction · 0.90
isFunctionAssignmentNodeFunction · 0.90
compileInlineExpressionFunction · 0.90
forEachFunction · 0.85
_compileAndEvaluateFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…