Skip to content

Commit

Permalink
Make decimalPlaces private
Browse files Browse the repository at this point in the history
  • Loading branch information
kurkle committed Mar 12, 2019
1 parent f5ff456 commit b8823ca
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
3 changes: 2 additions & 1 deletion src/core/core.helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,9 @@ module.exports = function() {
* i.e. the number of digits after the decimal point, of the value of this Number.
* @param {number} x - A number.
* @returns {number} The number of decimal places.
* @private
*/
helpers.decimalPlaces = function(x) {
helpers._decimalPlaces = function(x) {
if (!helpers.isFinite(x)) {
return;
}
Expand Down
2 changes: 1 addition & 1 deletion src/scales/scale.linearbase.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ function generateTicks(generationOptions, dataRange) {

if (stepSize || isNullOrUndef(precision)) {
// If a precision is not specified, calculate factor based on spacing
factor = Math.pow(10, helpers.decimalPlaces(spacing));
factor = Math.pow(10, helpers._decimalPlaces(spacing));
} else {
// If the user specified a precision, round to that number of decimal places
factor = Math.pow(10, precision);
Expand Down
16 changes: 8 additions & 8 deletions test/specs/core.helpers.tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,14 @@ describe('Core helper tests', function() {
});

it('should get the correct number of decimal places', function() {
expect(helpers.decimalPlaces(100)).toBe(0);
expect(helpers.decimalPlaces(1)).toBe(0);
expect(helpers.decimalPlaces(0)).toBe(0);
expect(helpers.decimalPlaces(0.01)).toBe(2);
expect(helpers.decimalPlaces(-0.01)).toBe(2);
expect(helpers.decimalPlaces('1')).toBe(undefined);
expect(helpers.decimalPlaces('')).toBe(undefined);
expect(helpers.decimalPlaces(undefined)).toBe(undefined);
expect(helpers._decimalPlaces(100)).toBe(0);
expect(helpers._decimalPlaces(1)).toBe(0);
expect(helpers._decimalPlaces(0)).toBe(0);
expect(helpers._decimalPlaces(0.01)).toBe(2);
expect(helpers._decimalPlaces(-0.01)).toBe(2);
expect(helpers._decimalPlaces('1')).toBe(undefined);
expect(helpers._decimalPlaces('')).toBe(undefined);
expect(helpers._decimalPlaces(undefined)).toBe(undefined);
});

it('should get an angle from a point', function() {
Expand Down

0 comments on commit b8823ca

Please sign in to comment.