handsontable
Version:
Handsontable is a JavaScript Data Grid available for React, Angular and Vue.
15 lines • 539 B
JavaScript
import { isNumericLike, getParsedNumber } from "../../../helpers/number.mjs";
import { isNullish } from "../../../dataMap/metaManager/utils.mjs";
/**
* Defines what value is set to a numeric-typed cell.
*
* @param {*} newValue The value to be set.
* @returns {*} The new value to be set.
*/
export function valueSetter(newValue) {
if (typeof newValue === 'string' && isNumericLike(newValue)) {
const parsedNumber = getParsedNumber(newValue);
return isNullish(parsedNumber) ? newValue : parsedNumber;
}
return newValue;
}