From 6dc36b0ef71e729d12f2b26a9ff7d5b647a52778 Mon Sep 17 00:00:00 2001 From: bordun Date: Tue, 4 Feb 2020 08:26:10 +0100 Subject: [PATCH] custom module: `send()` function casting numbers to integers instead of floats by default --- CHANGELOG.md | 1 + src/server/osc/index.js | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7033d500..47dfb19a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/src/server/osc/index.js b/src/server/osc/index.js index 47bb0356..f8e68043 100644 --- a/src/server/osc/index.js +++ b/src/server/osc/index.js @@ -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':