From a4ddafb5c8c4057f1783409a02124b9abb22749a Mon Sep 17 00:00:00 2001 From: grymmjack Date: Wed, 31 May 2023 17:01:56 -0400 Subject: [PATCH] Added type validation - when fail use default --- qb.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/qb.js b/qb.js index e5af79f..eceac3a 100644 --- a/qb.js +++ b/qb.js @@ -2817,9 +2817,9 @@ var QB = new function() { this.sub_Sound = async function(freq, duration, shape, decay, gain) { - if (shape == undefined) { shape = "square"; } - if (decay == undefined) { decay = 0.0; } - if (gain == undefined) { gain = 1.0; } + if (shape == undefined || (typeof shape != 'string')) { shape = "square"; } + if (decay == undefined || (typeof decay != 'number')) { decay = 0.0; } + if (gain == undefined || (typeof gain != 'number')) { gain = 1.0; } if (!(freq == 0 || (freq >= 32 && freq <= 32767))) { throw new Error("Frequency invalid - valid: 0 (delay), 32 to 32767"); }