added check for [bins] argument in fft method of P5, along with unit Test( in es6 style)
issue :

the bins arguments is very vulnerable , as there is no check to what user provides as the input to bins argument , suppose the user enters a negative value of bins by mistake , then it's a crash ! so there must be a check to what user gives input as "bins" arguments"
solution :
-
added a filter (safeBins) to what user enters as argument .

-
checks are esablished as shown

-
added a unit test for the function

@therewasaguy please review this Pr!
Also, just a note:
In the Web Audio API, the
AnalyserNode.frequencyBinCountisRead only(I'm looking at the MDN documentation for reference https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode). It is always half of the fftSize. So we're kind of doing things backwards in p5.Sound by allowing users to set the binSize directly. We're doing that because it seemed like it would be more intuitive to set a value that represents the array size you get from the analysis, rather than a value that is twice that amount... but I'm having second thoughts about that now.
yeah ! you are right ! but it is very intuitive and generous to provide user the flexibilty to choose length of array in which analysed data will be served to them !, and we are no where assigning the value to "AnalyserNode.frequencyBinCount" that means it is good to use , infact we are creating a level of abstraction that provides ease to user !, so we don't need to remove that ,however we can rename it , name other than bins because it seem to represent "AnalyserNode.frequencyBinCount" how about name "length" which represents the length of array !
I suggest testing the public methods, and making this a private method.
i was actually thinking the same , means i need to create a wrapper for this method ? or you have any other suggestions?
Do you think the functionality of
safeBinscould be incorporated intosafeBufferSize, rather than making it a separate method?
safeBufferSize have other checks than safeBIns has
Also in ,
https://github.com/processing/p5.js-sound/pull/419#issuecomment-603586872
i have agreed to the w3 specs and not giving our user the ability to change the bufferSIZe() and hence we don't need to add tests for it like in safeBins !! so after your confirmation I will close that PR !(#419)
i would like to draft this one until the module system work is done !