(
transOption: DataTransformOption,
upSourceList: Source[],
infoForPrint: { datasetIndex: number },
// If `pipeIndex` is null/undefined, no piped transform.
pipeIndex: number
)
| 390 | } |
| 391 | |
| 392 | function applySingleDataTransform( |
| 393 | transOption: DataTransformOption, |
| 394 | upSourceList: Source[], |
| 395 | infoForPrint: { datasetIndex: number }, |
| 396 | // If `pipeIndex` is null/undefined, no piped transform. |
| 397 | pipeIndex: number |
| 398 | ): Source[] { |
| 399 | let errMsg = ''; |
| 400 | if (!upSourceList.length) { |
| 401 | if (__DEV__) { |
| 402 | errMsg = 'Must have at least one upstream dataset.'; |
| 403 | } |
| 404 | throwError(errMsg); |
| 405 | } |
| 406 | if (!isObject(transOption)) { |
| 407 | if (__DEV__) { |
| 408 | errMsg = 'transform declaration must be an object rather than ' + typeof transOption + '.'; |
| 409 | } |
| 410 | throwError(errMsg); |
| 411 | } |
| 412 | |
| 413 | const transType = transOption.type; |
| 414 | const externalTransform = externalTransformMap.get(transType); |
| 415 | |
| 416 | if (!externalTransform) { |
| 417 | if (__DEV__) { |
| 418 | errMsg = 'Can not find transform on type "' + transType + '".'; |
| 419 | } |
| 420 | throwError(errMsg); |
| 421 | } |
| 422 | |
| 423 | // Prepare source |
| 424 | const extUpSourceList = map(upSourceList, upSource => createExternalSource(upSource, externalTransform)); |
| 425 | |
| 426 | const resultList = normalizeToArray( |
| 427 | externalTransform.transform({ |
| 428 | upstream: extUpSourceList[0], |
| 429 | upstreamList: extUpSourceList, |
| 430 | config: clone(transOption.config) |
| 431 | }) |
| 432 | ); |
| 433 | |
| 434 | if (__DEV__) { |
| 435 | if (transOption.print) { |
| 436 | const printStrArr = map(resultList, extSource => { |
| 437 | const pipeIndexStr = pipeIndex != null ? ' === pipe index: ' + pipeIndex : ''; |
| 438 | return [ |
| 439 | '=== dataset index: ' + infoForPrint.datasetIndex + pipeIndexStr + ' ===', |
| 440 | '- transform result data:', |
| 441 | makePrintable(extSource.data), |
| 442 | '- transform result dimensions:', |
| 443 | makePrintable(extSource.dimensions) |
| 444 | ].join('\n'); |
| 445 | }).join('\n'); |
| 446 | log(printStrArr); |
| 447 | } |
| 448 | } |
| 449 |
no test coverage detected
searching dependent graphs…