1
1
Fork 0
mirror of https://github.com/boxgaming/qbjs.git synced 2024-09-20 04:24:45 +00:00

Added type validation - when fail use default

This commit is contained in:
grymmjack 2023-05-31 17:01:56 -04:00
parent 7faf4a4e85
commit a4ddafb5c8

6
qb.js
View file

@ -2817,9 +2817,9 @@ var QB = new function() {
this.sub_Sound = async function(freq, duration, shape, decay, gain) { this.sub_Sound = async function(freq, duration, shape, decay, gain) {
if (shape == undefined) { shape = "square"; } if (shape == undefined || (typeof shape != 'string')) { shape = "square"; }
if (decay == undefined) { decay = 0.0; } if (decay == undefined || (typeof decay != 'number')) { decay = 0.0; }
if (gain == undefined) { gain = 1.0; } if (gain == undefined || (typeof gain != 'number')) { gain = 1.0; }
if (!(freq == 0 || (freq >= 32 && freq <= 32767))) { if (!(freq == 0 || (freq >= 32 && freq <= 32767))) {
throw new Error("Frequency invalid - valid: 0 (delay), 32 to 32767"); throw new Error("Frequency invalid - valid: 0 (delay), 32 to 32767");
} }