Skip to content

nf seems to have wrong prototypes #6994

Open
@IronBlood

Description

Most appropriate sub-area of p5.js?

  • Accessibility
  • Color
  • Core/Environment/Rendering
  • Data
  • DOM
  • Events
  • Image
  • IO
  • Math
  • Typography
  • Utilities
  • WebGL
  • Build process
  • Unit testing
  • Internationalization
  • Friendly errors
  • Other (specify if possible)

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:

  • nf(num, [left], [right])
  • nf(nums, [left], [right])

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:

  • result = nf(1234), if left is optional
  • result = nf([1234, 3.141516, 3.141516e-2], 2) for an array of numbers to format

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions