source: trip-planner-front/node_modules/hdr-histogram-js/dist/formatters.js

Last change on this file was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 1.2 KB
RevLine 
[6a3a178]1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3exports.floatFormatter = exports.keepSignificantDigits = exports.integerFormatter = void 0;
4const leftPadding = (size) => {
5 return (input) => {
6 if (input.length < size) {
7 return " ".repeat(size - input.length) + input;
8 }
9 return input;
10 };
11};
12exports.integerFormatter = (size) => {
13 const padding = leftPadding(size);
14 return (integer) => padding("" + integer);
15};
16const { floor, log10, pow } = Math;
17const numberOfDigits = (n) => floor(log10(n) + 1);
18exports.keepSignificantDigits = (digits) => (value) => {
19 const valueDigits = numberOfDigits(value);
20 if (valueDigits > digits) {
21 const extraDigits = valueDigits - digits;
22 const magnitude = pow(10, extraDigits);
23 return value - (value % magnitude);
24 }
25 return value;
26};
27exports.floatFormatter = (size, fractionDigits) => {
28 const numberFormatter = new Intl.NumberFormat("en-US", {
29 maximumFractionDigits: fractionDigits,
30 minimumFractionDigits: fractionDigits,
31 useGrouping: false,
32 });
33 const padding = leftPadding(size);
34 return (float) => padding(numberFormatter.format(float));
35};
36//# sourceMappingURL=formatters.js.map
Note: See TracBrowser for help on using the repository browser.