MCPcopy Index your code
hub / github.com/tdewolff/minify / detectSourceFormat

Function detectSourceFormat

_benchmarks/sample_echarts.js:19841–19875  ·  view source on GitHub ↗

* Note: An empty array will be detected as `SOURCE_FORMAT_ARRAY_ROWS`.

(data)

Source from the content-addressed store, hash-verified

19839
19840
19841 function detectSourceFormat(data) {
19842 var sourceFormat = SOURCE_FORMAT_UNKNOWN;
19843
19844 if (isTypedArray(data)) {
19845 sourceFormat = SOURCE_FORMAT_TYPED_ARRAY;
19846 } else if (isArray(data)) {
19847 // FIXME Whether tolerate null in top level array?
19848 if (data.length === 0) {
19849 sourceFormat = SOURCE_FORMAT_ARRAY_ROWS;
19850 }
19851
19852 for (var i = 0, len = data.length; i < len; i++) {
19853 var item = data[i];
19854
19855 if (item == null) {
19856 continue;
19857 } else if (isArray(item)) {
19858 sourceFormat = SOURCE_FORMAT_ARRAY_ROWS;
19859 break;
19860 } else if (isObject(item)) {
19861 sourceFormat = SOURCE_FORMAT_OBJECT_ROWS;
19862 break;
19863 }
19864 }
19865 } else if (isObject(data)) {
19866 for (var key in data) {
19867 if (hasOwn(data, key) && isArrayLike(data[key])) {
19868 sourceFormat = SOURCE_FORMAT_KEYED_COLUMNS;
19869 break;
19870 }
19871 }
19872 }
19873
19874 return sourceFormat;
19875 }
19876 /**
19877 * Determine the source definitions from data standalone dimensions definitions
19878 * are not specified.

Callers 2

createSourceFunction · 0.85
applySingleDataTransformFunction · 0.85

Calls 5

isTypedArrayFunction · 0.85
hasOwnFunction · 0.85
isArrayFunction · 0.70
isObjectFunction · 0.70
isArrayLikeFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…