Skip to content

Commit

Permalink
Merge pull request #1 from DiscoNova/wip/reduce-complexity
Browse files Browse the repository at this point in the history
Simplify code slightly
  • Loading branch information
DiscoNova authored Jul 11, 2019
2 parents d70166f + 8884695 commit 1928e21
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 11 deletions.
8 changes: 1 addition & 7 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1 @@

const symmetricRound = (x) => Math.round(Math.abs(x)) * Math.sign(x);

module.exports = {
symmetricRound,
default: symmetricRound
};
module.exports = (x) => Math.round(Math.abs(x)) * Math.sign(x);
10 changes: 7 additions & 3 deletions index.test.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@

const symmetricRound = require('./index.js').default;

expect(symmetricRound).toBeDefined();
const symmetricRound = require('./index.js');

describe('symmetricRound() is nice because it does', () => {

test('enable import with require()', () => {
expect(symmetricRound).toBeDefined();
expect(symmetricRound).toBeInstanceOf(Function);
// TODO: Should test ES6 "import xxx from yyy"!?
});

test('round numbers symmetrically', () => {
expect(symmetricRound(0.5)).toBe(1);
expect(symmetricRound(-0.5)).toBe(-1); // Symmetric result for negative input
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "symmetric-round",
"version": "0.0.3",
"version": "0.0.4",
"description": "A tiny utility function to perform symmetric rounding (a.k.a. \"commercial rounding\") on a number.",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit 1928e21

Please sign in to comment.