josdejong/mathjs

Document developer requirements/guidelines for the Number bundle

Aperta

#3559 aperta il 17 ott 2025

 (4 commenti) (0 reazioni) (0 assegnatari)JavaScript (1314 fork)batch import
documentationgood first issue

Metriche repository

Star
 (15.065 stelle)
Metriche merge PR
 (Metriche PR in attesa)

Descrizione

Recently, I have just been throwing any mathjs methods I create into the number bundle with their standard factories, on the theory that if their factory defines implementations for other types, those will just be ignored when the number-only instance is generated.

However, I was working on adding a scalarDivide() function (which would check if one vector is a scalar multiple of another, e.g., scalarDivide([1.5, 3], [1, 2]) = 1.5 but scalarDivide([2, 3], [1, 2]) = undefined), and I went to add it to factoriesNumber and discovered that neither dotMultiply nor dotDivide is in the number bundle. Yet these operations make perfect sense for ordinary arrays of numbers. So, it would be helpful to have some clarification:

  1. What is the criterion for a method to be included in the number bundle? Should dotMultiply and dotDivide be added, and the list of functions scanned for others that should be added? Or perhaps are there methods now in the number bundle that should be removed?

  2. Is there/could there be automated testing for what is and isn't in the number bundle?

  3. When does the implementation need to be changed for inclusion in the number bundle vs. when can the same factory just be included in factoriesNumber as in factoriesAny?

This guidance should be added to the "Implementing a new function" section of the README.

Guida contributor