processing / p5.js

p5.js is a client-side JS platform that empowers artists, designers, students, and anyone to learn to code and express themselves creatively on the web. It is based on the core principles of Processing. http://twitter.com/p5xjs —
http://p5js.org/
GNU Lesser General Public License v2.1
21.51k stars 3.29k forks source link

`nf` seems to have wrong prototypes #6994

Open IronBlood opened 5 months ago

IronBlood commented 5 months ago

Most appropriate sub-area of p5.js?

p5.js version

main branch

Web browser and version

No response

Operating system

No response

Steps to reproduce this

This is generally a report about the documentation and test cases.

From the reference, the prototypes for nf are:

However, from the source code, especially in doNf(num, left, right), there isn't check of type left === 'undefined', nor a default value for left, so when calling leftPart = leftPart.padStart(left, '0'), left cannot be undefined.

Also in the test suite of p5.prototype.nf, test cases are missing:

welcome[bot] commented 5 months ago

Welcome! 👋 Thanks for opening your first issue here! And to ensure the community is able to respond to your issue, please make sure to fill out the inputs in the issue forms. Thank you!

Akhilbisht798 commented 4 months ago

Hey, I am intrested in this isssue. As you said here.

 However, from the source code, especially in doNf(num, left, right), there isn't check of type left === 'undefined', nor a default value for left, so when calling leftPart = leftPart.padStart(left, '0'), left cannot be undefined

did you meant that left can be undefined because that will make more sense if i am not wrong.

Akhilbisht798 commented 4 months ago

I can be wrong in this but i think p5._validateParameters('nf', arguments); Here the arguments are being checked so that they are always correct or something of that sort. But for test cases i think you are right we should have a test for array and test for only right argument.