MCPcopy Create free account
hub / github.com/chartbrew/chartbrew / determineType

Function determineType

server/modules/determineType.js:34–65  ·  view source on GitHub ↗
(data, operation)

Source from the content-addressed store, hash-verified

32}
33
34function determineType(data, operation) {
35 let dataType;
36 if (data !== null && typeof data === "object" && data instanceof Array) {
37 dataType = "array";
38 }
39 if (data !== null && typeof data === "object" && !(data instanceof Array)) {
40 dataType = "object";
41 }
42 if (typeof data !== "object" && !(data instanceof Array) && typeof data === "boolean") {
43 dataType = "boolean";
44 }
45 if (typeof data !== "object" && !(data instanceof Array) && (typeof data === "number" || `${data}`.match(checkNumbersOnly))) {
46 dataType = "number";
47 }
48 if (typeof data !== "object" && !(data instanceof Array) && typeof data === "string" && !`${data}`.match(checkNumbersOnly)) {
49 dataType = "string";
50 }
51
52 try {
53 if (isLikelyDate(data, dataType)) {
54 dataType = "date";
55 }
56 } catch (e) {
57 //
58 }
59
60 if (checkNumbersOnly.test(data) && (operation === "sum" || operation === "avg")) {
61 dataType = "number";
62 }
63
64 return dataType;
65}
66
67module.exports = determineType;

Callers 8

findFieldsFunction · 0.70
initFunction · 0.70
normalizeKeysFunction · 0.70
normalizeValuesFunction · 0.70
isArrayPresentFunction · 0.50
runDataRequestFunction · 0.50
populateReferencesFunction · 0.50
getDataMethod · 0.50

Calls 1

isLikelyDateFunction · 0.70

Tested by

no test coverage detected