custom module: send() function casting numbers to integers instead of floats by default

This commit is contained in:
bordun 2020-02-04 08:26:10 +01:00
parent 40a399fa1f
commit 6dc36b0ef7
2 changed files with 3 additions and 2 deletions

View file

@ -4,6 +4,7 @@
- bug fixes
- modal: error when `label` depends on a child's property
- custom module: `send()` function casting numbers to integers instead of floats by default
## 0.49.0

View file

@ -129,10 +129,10 @@ class OscServer {
switch (typeof arg) {
case 'number':
var typeTagMatch = typeof precision == 'string' ? precision.match(/[0-9]+([a-zA-Z]{1})/) : null,
typeTag = typeTagMatch === null ? precision == 0 ? 'i' : 'f' : typeTagMatch[1],
typeTag = typeTagMatch === null ? precision === 0 ? 'i' : 'f' : typeTagMatch[1],
precisionValue = parseFloat(precision) || 0
return {type: typeTag, value: parseFloat(arg.toFixed(precisionValue))}
return {type: typeTag, value: precision === undefined ? arg : parseFloat(arg.toFixed(precisionValue))}
case 'boolean':
return {type: arg ? 'T' : 'F', value: arg}
case 'object':