MCPcopy Index your code
hub / github.com/microsoft/SandDance / inferType

Function inferType

docs/app/js/sanddance-app.js:109061–109073  ·  view source on GitHub ↗
(values, field)

Source from the content-addressed store, hash-verified

109059 "date"
109060];
109061function inferType(values, field) {
109062 if (!values || !values.length) return "unknown";
109063 const n = values.length, m = typeTests.length, a = typeTests.map((_, i)=>i + 1);
109064 for(let i1 = 0, t = 0, j, value; i1 < n; ++i1){
109065 value = field ? values[i1][field] : values[i1];
109066 for(j = 0; j < m; ++j)if (a[j] && isValid(value) && !typeTests[j](value)) {
109067 a[j] = 0;
109068 ++t;
109069 if (t === typeTests.length) return "string";
109070 }
109071 }
109072 return typeList[a.reduce((u, v)=>u === 0 ? v : u, 0) - 1];
109073}
109074function inferTypes(data, fields) {
109075 return fields.reduce((types, field)=>{
109076 types[field] = inferType(data, field);

Callers 1

inferTypesFunction · 0.70

Calls 1

isValidFunction · 0.70

Tested by

no test coverage detected