UNPKG

@mikezimm/npmfunctions

Version:
79 lines 3.62 kB
"use strict"; /*** * d888888b .88b d88. d8888b. .d88b. d8888b. d888888b .d88b. d88888b d88888b d888888b .o88b. d888888b .d8b. db * `88' 88'YbdP`88 88 `8D .8P Y8. 88 `8D `~~88~~' .8P Y8. 88' 88' `88' d8P Y8 `88' d8' `8b 88 * 88 88 88 88 88oodD' 88 88 88oobY' 88 88 88 88ooo 88ooo 88 8P 88 88ooo88 88 * 88 88 88 88 88~~~ 88 88 88`8b 88 88 88 88~~~ 88~~~ 88 8b 88 88~~~88 88 * .88. 88 88 88 88 `8b d8' 88 `88. 88 `8b d8' 88 88 .88. Y8b d8 .88. 88 88 88booo. * Y888888P YP YP YP 88 `Y88P' 88 YD YP `Y88P' YP YP Y888888P `Y88P' Y888888P YP YP Y88888P * * */ Object.defineProperty(exports, "__esModule", { value: true }); exports.getDetailValueType = void 0; /*** * d888888b .88b d88. d8888b. .d88b. d8888b. d888888b d8b db d8888b. .88b d88. d88888b db db d8b db .o88b. d888888b d888888b .d88b. d8b db .d8888. * `88' 88'YbdP`88 88 `8D .8P Y8. 88 `8D `~~88~~' 888o 88 88 `8D 88'YbdP`88 88' 88 88 888o 88 d8P Y8 `~~88~~' `88' .8P Y8. 888o 88 88' YP * 88 88 88 88 88oodD' 88 88 88oobY' 88 88V8o 88 88oodD' 88 88 88 88ooo 88 88 88V8o 88 8P 88 88 88 88 88V8o 88 `8bo. * 88 88 88 88 88~~~ 88 88 88`8b 88 88 V8o88 88~~~ 88 88 88 88~~~ 88 88 88 V8o88 8b 88 88 88 88 88 V8o88 `Y8b. * .88. 88 88 88 88 `8b d8' 88 `88. 88 88 V888 88 88 88 88 88 88b d88 88 V888 Y8b d8 88 .88. `8b d8' 88 V888 db 8D * Y888888P YP YP YP 88 `Y88P' 88 YD YP VP V8P 88 YP YP YP YP ~Y8888P' VP V8P `Y88P' YP Y888888P `Y88P' VP V8P `8888Y' * * */ var checks_1 = require("./Time/checks"); /** * Gets actual likely type * @param fieldValue */ function getDetailValueType(fieldValue) { var fieldType = typeof fieldValue; var result = 'unknown'; if (fieldValue === undefined) { result = 'undefined'; } else if (fieldValue === null) { result = 'null'; } else if (fieldType === 'function') { result = 'function'; } else if (fieldType === 'string') { if (isNaN(fieldValue)) { //This is a string or date string if ((0, checks_1.isStringValidDate)(fieldValue, 'common')) { result = 'datestring'; } else { result = 'string'; } } else { result = 'numberstring'; } } else if (fieldType === 'boolean') { result = 'boolean'; } else if (fieldType === 'number') { result = 'number'; } else if (fieldType === 'object') { //If it's a multi-choice; return all choices in an array. if (Array.isArray(fieldValue)) { result = 'array'; //Else just stringify it } else { var keys = JSON.stringify(Object.keys(fieldValue)); if (keys === "['Description','Url']" || keys === '["Description","Url"]') { result = 'link'; } else { result = 'object'; } } } return result; } exports.getDetailValueType = getDetailValueType; //# sourceMappingURL=typeServices.js.map