Skip to content

Commit 3052a50

Browse files
committed
MathContext rename
1 parent 8d6aaf7 commit 3052a50

File tree

14 files changed

+85
-85
lines changed

14 files changed

+85
-85
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,15 @@ console.log(v.toString()); // 2
4949
You can use MathContext object to set precision and rounding mode for a specific operation:
5050

5151
```javascript
52-
const { Big, MathContext, RoundingMode } = require('bigdecimal.js');
52+
const { Big, MC, RoundingMode } = require('bigdecimal.js');
5353

5454
const x = Big('1');
5555
const y = Big('3');
5656

57-
const res1 = x.divide(y, MathContext(3)); // can be used without `new`
57+
const res1 = x.divide(y, MC(3)); // can be used without `new`
5858
console.log(res1.toString()); // 0.333
5959

60-
const res2 = x.divide(y, new MathContext(3, RoundingMode.UP));
60+
const res2 = x.divide(y, new MC(3, RoundingMode.UP));
6161
console.log(res2.toString()); // 0.334
6262

6363
try {

src/bigdecimal.ts

Lines changed: 58 additions & 58 deletions
Large diffs are not rendered by default.

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export { Big, RoundingMode, MathContext } from './bigdecimal';
1+
export { Big, RoundingMode, MC } from './bigdecimal';

test/abs.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
'use strict';
2-
const { Big, MathContext } = require('../lib/bigdecimal');
2+
const { Big, MC } = require('../lib/bigdecimal');
33
const chai = require('chai');
44
const testCases = require('../util/output/absTestCases.json');
55
chai.should();
@@ -10,7 +10,7 @@ describe('Absolute value test', function () {
1010
for (const test of testCases) {
1111
const absOp = () => {
1212
return Big(test.args[0]).abs(
13-
new MathContext(test.args[1], test.args[2])
13+
new MC(test.args[1], test.args[2])
1414
).toString();
1515
};
1616
if (test.result === 'errorThrown') {

test/add.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
'use strict';
2-
const { Big, MathContext } = require('../lib/bigdecimal');
2+
const { Big, MC } = require('../lib/bigdecimal');
33
const chai = require('chai');
44
const testCases = require('../util/output/additionTestCases.json');
55
const invalidTests = require('./invalidTests');
@@ -12,7 +12,7 @@ describe('Addition test', function () {
1212
const addition = () => {
1313
return Big(test.args[0]).add(
1414
Big(test.args[1]),
15-
MathContext(test.args[2], test.args[3])
15+
MC(test.args[2], test.args[3])
1616
).toString();
1717
};
1818
if (test.result === 'errorThrown') {

test/divide.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
'use strict';
2-
const { Big, MathContext } = require('../lib/bigdecimal');
2+
const { Big, MC } = require('../lib/bigdecimal');
33
const chai = require('chai');
44
const testCases = require('../util/output/divisionTestCases.json');
55
const invalidTests = require('./invalidTests');
@@ -12,7 +12,7 @@ describe('Division test', function () {
1212
const division = () => {
1313
return Big(test.args[0]).divide(
1414
Big(test.args[1]),
15-
new MathContext(test.args[2], test.args[3])
15+
new MC(test.args[2], test.args[3])
1616
).toString();
1717
};
1818
if (test.result === 'errorThrown') {

test/divideAndRemainder.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
'use strict';
2-
const { Big, MathContext } = require('../lib/bigdecimal');
2+
const { Big, MC } = require('../lib/bigdecimal');
33
const chai = require('chai');
44
const testCases = require('../util/output/divideAndRemainderTestCases.json');
55
const invalidTests = require('./invalidTests');
@@ -12,7 +12,7 @@ describe('DivideAndRemainder test', function () {
1212
const divideAndRemainderOp = () => {
1313
const result = Big(test.args[0]).divideAndRemainder(
1414
Big(test.args[1]),
15-
new MathContext(test.args[2], test.args[3])
15+
new MC(test.args[2], test.args[3])
1616
);
1717
return result;
1818
};

test/divideToIntegralValue.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
'use strict';
2-
const { Big, MathContext } = require('../lib/bigdecimal');
2+
const { Big, MC } = require('../lib/bigdecimal');
33
const chai = require('chai');
44
const testCases = require('../util/output/divideToIntegralValueTestCases.json');
55
const invalidTests = require('./invalidTests');
@@ -12,7 +12,7 @@ describe('DivideToIntegralValue test', function () {
1212
const divideToIntegralValueOp = () => {
1313
return Big(test.args[0]).divideToIntegralValue(
1414
Big(test.args[1]),
15-
new MathContext(test.args[2], test.args[3])
15+
new MC(test.args[2], test.args[3])
1616
).toString();
1717
};
1818
if (test.result === 'errorThrown') {

test/multiply.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
'use strict';
2-
const { Big, MathContext } = require('../lib/bigdecimal');
2+
const { Big, MC } = require('../lib/bigdecimal');
33
const chai = require('chai');
44
const testCases = require('../util/output/multiplicationTestCases.json');
55
const invalidTests = require('./invalidTests');
@@ -12,7 +12,7 @@ describe('Multiplication test', function () {
1212
const multiplication = () => {
1313
return Big(test.args[0]).multiply(
1414
Big(test.args[1]),
15-
new MathContext(test.args[2], test.args[3])
15+
new MC(test.args[2], test.args[3])
1616
).toString();
1717
};
1818
if (test.result === 'errorThrown') {

test/negate.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
'use strict';
2-
const { Big, MathContext } = require('../lib/bigdecimal');
2+
const { Big, MC } = require('../lib/bigdecimal');
33
const chai = require('chai');
44
const testCases = require('../util/output/negateTestCases.json');
55
chai.should();
@@ -10,7 +10,7 @@ describe('Negate test', function () {
1010
for (const test of testCases) {
1111
const negateOp = () => {
1212
return Big(test.args[0]).negate(
13-
new MathContext(test.args[1], test.args[2])
13+
new MC(test.args[1], test.args[2])
1414
).toString();
1515
};
1616
if (test.result === 'errorThrown') {

0 commit comments

Comments
 (0)