MCPcopy
hub / github.com/tdewolff/minify / applySingleDataTransform

Function applySingleDataTransform

_benchmarks/sample_echarts.js:21446–21580  ·  view source on GitHub ↗
(transOption, upSourceList, infoForPrint, // If `pipeIndex` is null/undefined, no piped transform.
    pipeIndex)

Source from the content-addressed store, hash-verified

21444 }
21445
21446 function applySingleDataTransform(transOption, upSourceList, infoForPrint, // If `pipeIndex` is null/undefined, no piped transform.
21447 pipeIndex) {
21448 var errMsg = '';
21449
21450 if (!upSourceList.length) {
21451 if ("development" !== 'production') {
21452 errMsg = 'Must have at least one upstream dataset.';
21453 }
21454
21455 throwError(errMsg);
21456 }
21457
21458 if (!isObject(transOption)) {
21459 if ("development" !== 'production') {
21460 errMsg = 'transform declaration must be an object rather than ' + typeof transOption + '.';
21461 }
21462
21463 throwError(errMsg);
21464 }
21465
21466 var transType = transOption.type;
21467 var externalTransform = externalTransformMap.get(transType);
21468
21469 if (!externalTransform) {
21470 if ("development" !== 'production') {
21471 errMsg = 'Can not find transform on type "' + transType + '".';
21472 }
21473
21474 throwError(errMsg);
21475 } // Prepare source
21476
21477
21478 var extUpSourceList = map(upSourceList, function (upSource) {
21479 return createExternalSource(upSource, externalTransform);
21480 });
21481 var resultList = normalizeToArray(externalTransform.transform({
21482 upstream: extUpSourceList[0],
21483 upstreamList: extUpSourceList,
21484 config: clone(transOption.config)
21485 }));
21486
21487 if ("development" !== 'production') {
21488 if (transOption.print) {
21489 var printStrArr = map(resultList, function (extSource) {
21490 var pipeIndexStr = pipeIndex != null ? ' === pipe index: ' + pipeIndex : '';
21491 return ['=== dataset index: ' + infoForPrint.datasetIndex + pipeIndexStr + ' ===', '- transform result data:', makePrintable(extSource.data), '- transform result dimensions:', makePrintable(extSource.dimensions)].join('\n');
21492 }).join('\n');
21493 consoleLog(printStrArr);
21494 }
21495 }
21496
21497 return map(resultList, function (result, resultIndex) {
21498 var errMsg = '';
21499
21500 if (!isObject(result)) {
21501 if ("development" !== 'production') {
21502 errMsg = 'A transform should not return some empty results.';
21503 }

Callers 1

applyDataTransformFunction · 0.85

Calls 11

throwErrorFunction · 0.85
createExternalSourceFunction · 0.85
normalizeToArrayFunction · 0.85
makePrintableFunction · 0.85
consoleLogFunction · 0.85
detectSourceFormatFunction · 0.85
isSupportedSourceFormatFunction · 0.85
createSourceFunction · 0.85
isObjectFunction · 0.70
mapFunction · 0.70
cloneFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…