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

Function createExternalSource

_benchmarks/sample_echarts.js:21209–21313  ·  view source on GitHub ↗
(internalSource, externalTransform)

Source from the content-addressed store, hash-verified

21207 }();
21208
21209 function createExternalSource(internalSource, externalTransform) {
21210 var extSource = new ExternalSource();
21211 var data = internalSource.data;
21212 var sourceFormat = extSource.sourceFormat = internalSource.sourceFormat;
21213 var sourceHeaderCount = internalSource.startIndex;
21214 var errMsg = '';
21215
21216 if (internalSource.seriesLayoutBy !== SERIES_LAYOUT_BY_COLUMN) {
21217 // For the logic simplicity in transformer, only 'culumn' is
21218 // supported in data transform. Otherwise, the `dimensionsDefine`
21219 // might be detected by 'row', which probably confuses users.
21220 if ("development" !== 'production') {
21221 errMsg = '`seriesLayoutBy` of upstream dataset can only be "column" in data transform.';
21222 }
21223
21224 throwError(errMsg);
21225 } // [MEMO]
21226 // Create a new dimensions structure for exposing.
21227 // Do not expose all dimension info to users directly.
21228 // Becuase the dimension is probably auto detected from data and not might reliable.
21229 // Should not lead the transformers to think that is relialbe and return it.
21230 // See [DIMENSION_INHERIT_RULE] in `sourceManager.ts`.
21231
21232
21233 var dimensions = [];
21234 var dimsByName = {};
21235 var dimsDef = internalSource.dimensionsDefine;
21236
21237 if (dimsDef) {
21238 each(dimsDef, function (dimDef, idx) {
21239 var name = dimDef.name;
21240 var dimDefExt = {
21241 index: idx,
21242 name: name,
21243 displayName: dimDef.displayName
21244 };
21245 dimensions.push(dimDefExt); // Users probably not sepcify dimension name. For simplicity, data transform
21246 // do not generate dimension name.
21247
21248 if (name != null) {
21249 // Dimension name should not be duplicated.
21250 // For simplicity, data transform forbid name duplication, do not generate
21251 // new name like module `completeDimensions.ts` did, but just tell users.
21252 var errMsg_1 = '';
21253
21254 if (hasOwn(dimsByName, name)) {
21255 if ("development" !== 'production') {
21256 errMsg_1 = 'dimension name "' + name + '" duplicated.';
21257 }
21258
21259 throwError(errMsg_1);
21260 }
21261
21262 dimsByName[name] = dimDefExt;
21263 }
21264 });
21265 } // If dimension definitions are not defined and can not be detected.
21266 // e.g., pure data `[[11, 22], ...]`.

Callers 1

applySingleDataTransformFunction · 0.85

Calls 7

throwErrorFunction · 0.85
hasOwnFunction · 0.85
getRawSourceItemGetterFunction · 0.85
bindFunction · 0.85
getRawSourceDataCounterFunction · 0.85
getRawSourceValueGetterFunction · 0.85
eachFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…