This is what I was doing in node-red-contrib-owfs:
function parseResult(result) {
if (typeof result.match === 'function') {
if (result.match(/^\-?\d+\.\d+$/)) {
return parseFloat(result);
} else if (result.match(/^\-?\d+$/)) {
return parseInt(result);
}
}
return result;
}