Skip to content

Commit

Permalink
[New] add round
Browse files Browse the repository at this point in the history
  • Loading branch information
ljharb committed Dec 19, 2024
1 parent e96be8f commit 7cfb044
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ ES Math-related intrinsics and helpers, robustly cached.
- `min`
- `mod`
- `pow`
- `round`
- `sign`
- `constants/maxArrayLength`
- `constants/maxSafeInteger`
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"./mod": "./mod.js",
"./pow": "./pow.js",
"./sign": "./sign.js",
"./round": "./round.js",
"./constants/maxArrayLength": "./constants/maxArrayLength.js",
"./constants/maxSafeInteger": "./constants/maxSafeInteger.js",
"./constants/maxValue": "./constants/maxValue.js",
Expand Down
1 change: 1 addition & 0 deletions round.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export = Math.round;
4 changes: 4 additions & 0 deletions round.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
'use strict';

/** @type {import('./round')} */
module.exports = Math.round;
9 changes: 9 additions & 0 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ var max = require('../max');
var min = require('../min');
var mod = require('../mod');
var pow = require('../pow');
var round = require('../round');
var sign = require('../sign');

var maxArrayLength = require('../constants/maxArrayLength');
Expand Down Expand Up @@ -160,6 +161,14 @@ test('pow', function (t) {
t.end();
});

test('round', function (t) {
t.equal(round(1.1), 1, 'round(1.1) === 1');
t.equal(round(1.5), 2, 'round(1.5) === 2');
t.equal(round(1.9), 2, 'round(1.9) === 2');

t.end();
});

test('sign', function (t) {
t.equal(sign(-1), -1, 'sign(-1) === -1');
t.equal(sign(+1), +1, 'sign(+1) === +1');
Expand Down

0 comments on commit 7cfb044

Please sign in to comment.