mentie 0.5.0 → 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3,13 +3,16 @@
3
3
  *
4
4
  * @param {number} number - The number to round.
5
5
  * @param {number} [decimals=4] - The number of decimals to round to. Default is 4.
6
+ * @param {string} [direction] - The direction to round ('up' or 'down'). If not specified, standard rounding is used.
6
7
  * @returns {number} The rounded number.
7
8
  */
8
- export const round_number_to_decimals = ( number, decimals=4 ) => {
9
+ export const round_number_to_decimals = ( number, decimals=4, direction ) => {
9
10
 
10
11
  if( number == undefined ) return ''
11
12
 
12
13
  const factor = 10 ** decimals
14
+ if( direction === 'up' ) return Math.ceil( number * factor ) / factor
15
+ if( direction === 'down' ) return Math.floor( number * factor ) / factor
13
16
  return Math.round( number * factor ) / factor
14
17
  }
15
18
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mentie",
3
- "version": "0.5.0",
3
+ "version": "0.5.1",
4
4
  "description": "Mentor's toolbelt",
5
5
  "type": "module",
6
6
  "main": "index.js",