Skip to content

Commit 20d9ba9

Browse files
committed
#147 Change toJSON to be an alias of toString
1 parent e82dd1d commit 20d9ba9

File tree

2 files changed

+16
-34
lines changed

2 files changed

+16
-34
lines changed

big.js

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -919,11 +919,15 @@
919919

920920

921921
/*
922-
* Return a string representing the value of this Big in exponential notation.
923-
* Include the sign for negative zero.
922+
* Return a string representing the value of this Big.
923+
* Return exponential notation if this Big has a positive exponent equal to or greater than
924+
* Big.PE, or a negative exponent equal to or less than Big.NE.
925+
* Omit the sign for negative zero.
924926
*/
925-
P.toJSON = function () {
926-
return stringify(this, true, true);
927+
P.toJSON = P.toString = function () {
928+
var x = this,
929+
Big = x.constructor;
930+
return stringify(x, x.e <= Big.NE || x.e >= Big.PE, !!x.c[0]);
927931
};
928932

929933

@@ -965,19 +969,6 @@
965969
};
966970

967971

968-
/*
969-
* Return a string representing the value of this Big.
970-
* Return exponential notation if this Big has a positive exponent equal to or greater than
971-
* Big.PE, or a negative exponent equal to or less than Big.NE.
972-
* Omit the sign for negative zero.
973-
*/
974-
P.toString = function () {
975-
var x = this,
976-
Big = x.constructor;
977-
return stringify(x, x.e <= Big.NE || x.e >= Big.PE, !!x.c[0]);
978-
};
979-
980-
981972
/*
982973
* Return a string representing the value of this Big.
983974
* Return exponential notation if this Big has a positive exponent equal to or greater than

big.mjs

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -916,11 +916,15 @@ P.toFixed = function (dp, rm) {
916916

917917

918918
/*
919-
* Return a string representing the value of this Big in exponential notation.
920-
* Include the sign for negative zero.
919+
* Return a string representing the value of this Big.
920+
* Return exponential notation if this Big has a positive exponent equal to or greater than
921+
* Big.PE, or a negative exponent equal to or less than Big.NE.
922+
* Omit the sign for negative zero.
921923
*/
922-
P.toJSON = function () {
923-
return stringify(this, true, true);
924+
P.toJSON = P.toString = function () {
925+
var x = this,
926+
Big = x.constructor;
927+
return stringify(x, x.e <= Big.NE || x.e >= Big.PE, !!x.c[0]);
924928
};
925929

926930

@@ -962,19 +966,6 @@ P.toPrecision = function (sd, rm) {
962966
};
963967

964968

965-
/*
966-
* Return a string representing the value of this Big.
967-
* Return exponential notation if this Big has a positive exponent equal to or greater than
968-
* Big.PE, or a negative exponent equal to or less than Big.NE.
969-
* Omit the sign for negative zero.
970-
*/
971-
P.toString = function () {
972-
var x = this,
973-
Big = x.constructor;
974-
return stringify(x, x.e <= Big.NE || x.e >= Big.PE, !!x.c[0]);
975-
};
976-
977-
978969
/*
979970
* Return a string representing the value of this Big.
980971
* Return exponential notation if this Big has a positive exponent equal to or greater than

0 commit comments

Comments
 (0)