devextreme
Version:
HTML5 JavaScript Component Suite for Responsive Web Development
51 lines (50 loc) • 1.46 kB
JavaScript
/**
* DevExtreme (esm/__internal/viz/components/parse_utils.js)
* Version: 25.2.3
* Build date: Fri Dec 12 2025
*
* Copyright (c) 2012 - 2025 Developer Express Inc. ALL RIGHTS RESERVED
* Read about DevExtreme licensing here: https://js.devexpress.com/Licensing/
*/
import {
noop
} from "../../../core/utils/common";
import dateSerialization from "../../../core/utils/date_serialization";
import {
isDefined
} from "../../../core/utils/type";
const parsers = {
string: val => isDefined(val) ? `${val}` : val,
numeric(val) {
if (!isDefined(val)) {
return val
}
let parsedVal = Number(val);
if (isNaN(parsedVal)) {
parsedVal = void 0
}
return parsedVal
},
datetime(val) {
if (!isDefined(val)) {
return val
}
let parsedVal;
const numVal = Number(val);
if (!isNaN(numVal)) {
parsedVal = new Date(numVal)
} else {
parsedVal = dateSerialization.deserializeDate(val)
}
if (isNaN(Number(parsedVal))) {
parsedVal = void 0
}
return parsedVal
}
};
export function correctValueType(type) {
return "numeric" === type || "datetime" === type || "string" === type ? type : ""
}
export const getParser = function(valueType) {
return parsers[correctValueType(valueType)] || noop
};