@d3plus/format 3.0.16 → 3.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 D3plus
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,5 +1,8 @@
1
1
  # @d3plus/format
2
-
2
+
3
+ [![NPM version](https://img.shields.io/npm/v/@d3plus/format.svg)](https://www.npmjs.com/package/@d3plus/format)
4
+ [![codecov](https://codecov.io/gh/d3plus/d3plus/graph/badge.svg?flag=format)](https://codecov.io/gh/d3plus/d3plus/flags)
5
+
3
6
  JavaScript formatters for localized numbers and dates.
4
7
 
5
8
  ## Installing
@@ -7,10 +10,10 @@ JavaScript formatters for localized numbers and dates.
7
10
  If using npm, `npm install @d3plus/format`. Otherwise, you can download the [latest release from GitHub](https://github.com/d3plus/d3plus/releases/latest) or load from a [CDN](https://cdn.jsdelivr.net/npm/@d3plus/format).
8
11
 
9
12
  ```js
10
- import modules from "@d3plus/format";
13
+ import {*} from "@d3plus/format";
11
14
  ```
12
15
 
13
- In vanilla JavaScript, a `d3plus` global is exported from the pre-bundled version:
16
+ In a vanilla environment, a `d3plus` global is exported from the pre-bundled version:
14
17
 
15
18
  ```html
16
19
  <script src="https://cdn.jsdelivr.net/npm/@d3plus/format"></script>
@@ -21,55 +24,103 @@ In vanilla JavaScript, a `d3plus` global is exported from the pre-bundled versio
21
24
 
22
25
  ## Examples
23
26
 
24
- Live examples can be found on [d3plus.org](https://d3plus.org/), which includes a collection of example visualizations using @d3plus/react.
27
+ Live examples can be found on [d3plus.org](https://d3plus.org/), which includes a collection of example visualizations using [@d3plus/react](https://github.com/d3plus/d3plus/tree/main/packages/react).
25
28
 
26
29
  ## API Reference
27
30
 
28
- #####
29
- * [format](#format) - An extension to d3's [format](https://github.com/d3/d3-format#api-reference) function that adds more string formatting types and localizations.
30
- * [formatAbbreviate](#formatAbbreviate) - Formats a number to an appropriate number of decimal places and rounding, adding suffixes if applicable (ie. `1200000` to `"1.2M"`).
31
- * [formatDate](#formatDate) - A default set of date formatters, which takes into account both the interval in between in each data point but also the start/end data points.
32
- * [formatDefaultLocale](#formatDefaultLocale) - An extension to d3's [formatDefaultLocale](https://github.com/d3/d3-format#api-reference) function that allows setting the locale globally for formatters.
31
+ | Functions | Description |
32
+ | --- | --- |
33
+ | [`format`](#format) | |
34
+ | [`formatAbbreviate`](#formatabbreviate) | Formats a number to an appropriate number of decimal places and rounding, adding suffixes if applicable (ie. `1200000` t |
35
+ | [`formatDate`](#formatdate) | A default set of date formatters, which takes into account both the interval in between in each data point but also the |
36
+ | [`formatDefaultLocale`](#formatdefaultlocale) | An extension to d3's [formatDefaultLocale](https://github.com/d3/d3-format#api-reference) function that allows setting t |
37
+
38
+ ## Functions
39
+
40
+ <a id="format"></a>
41
+
42
+ ### format()
33
43
 
34
- ---
44
+ > **format**(`specifier`: `string`): `Formatter`
35
45
 
36
- <a name="format"></a>
37
- #### d3plus.**format**(specifier) [<>](https://github.com/d3plus/d3plus/blob/main/packages/format/src/format.js#L4)
46
+ Defined in: [format.ts:10](https://github.com/d3plus/d3plus/blob/fe174c3153bf379a226e4a41b6a8492a86c3a1b7/packages/format/src/format.ts#L10)
38
47
 
39
- An extension to d3's [format](https://github.com/d3/d3-format#api-reference) function that adds more string formatting types and localizations.
48
+ #### Parameters
40
49
 
50
+ | Parameter | Type |
51
+ | ------ | ------ |
52
+ | `specifier` | `string` |
41
53
 
42
- This is a global function
54
+ #### Returns
43
55
 
44
- ---
56
+ `Formatter`
45
57
 
46
- <a name="formatAbbreviate"></a>
47
- #### d3plus.**formatAbbreviate**(n, locale) [<>](https://github.com/d3plus/d3plus/blob/main/packages/format/src/formatAbbreviate.js#L38)
58
+ ***
59
+
60
+ <a id="formatabbreviate"></a>
61
+
62
+ ### formatAbbreviate()
63
+
64
+ > **formatAbbreviate**(`n`: `string` \| `number`, `locale?`: `string` \| `FormatLocaleDefinition`, `precision?`: `string`): `string`
65
+
66
+ Defined in: [formatAbbreviate.ts:55](https://github.com/d3plus/d3plus/blob/fe174c3153bf379a226e4a41b6a8492a86c3a1b7/packages/format/src/formatAbbreviate.ts#L55)
48
67
 
49
68
  Formats a number to an appropriate number of decimal places and rounding, adding suffixes if applicable (ie. `1200000` to `"1.2M"`).
50
69
 
70
+ #### Parameters
71
+
72
+ | Parameter | Type | Default | Description |
73
+ | ------ | ------ | ------ | ------ |
74
+ | `n` | `string` \| `number` | *required* | The number to be formatted. |
75
+ | `locale` | `string` \| `FormatLocaleDefinition` | `"en-US"` | The locale config to be used. If an object is provided, the function will format the numbers according to the object. The object must include `suffixes`, `delimiter` and `currency` properties. |
76
+ | `precision?` | `string` | *required* | Number of significant digits to display. |
51
77
 
52
- This is a global function
78
+ #### Returns
53
79
 
54
- ---
80
+ `string`
55
81
 
56
- <a name="formatDate"></a>
57
- #### d3plus.**formatDate**(d, dataArray, [formatter]) [<>](https://github.com/d3plus/d3plus/blob/main/packages/format/src/formatDate.js#L4)
82
+ ***
83
+
84
+ <a id="formatdate"></a>
85
+
86
+ ### formatDate()
87
+
88
+ > **formatDate**(`d`: `Date`, `dataArray`: `Date`[], `formatter?`: `DateFormatter`): `string`
89
+
90
+ Defined in: [formatDate.ts:12](https://github.com/d3plus/d3plus/blob/fe174c3153bf379a226e4a41b6a8492a86c3a1b7/packages/format/src/formatDate.ts#L12)
58
91
 
59
92
  A default set of date formatters, which takes into account both the interval in between in each data point but also the start/end data points.
60
93
 
94
+ #### Parameters
95
+
96
+ | Parameter | Type | Default | Description |
97
+ | ------ | ------ | ------ | ------ |
98
+ | `d` | `Date` | *required* | The date to format. |
99
+ | `dataArray` | `Date`[] | *required* | The full array of ordered Date Objects. |
100
+ | `formatter` | `DateFormatter` | `timeFormat` | Optional custom format string or function. |
101
+
102
+ #### Returns
103
+
104
+ `string`
105
+
106
+ ***
107
+
108
+ <a id="formatdefaultlocale"></a>
61
109
 
62
- This is a global function
110
+ ### formatDefaultLocale()
63
111
 
64
- ---
112
+ > **formatDefaultLocale**(`definition`: `FormatLocaleDefinition`): `Record`\<`string`, `unknown`\>
65
113
 
66
- <a name="formatDefaultLocale"></a>
67
- #### d3plus.**formatDefaultLocale**(definition) [<>](https://github.com/d3plus/d3plus/blob/main/packages/format/src/formatDefaultLocale.js#L4)
114
+ Defined in: [formatDefaultLocale.ts:8](https://github.com/d3plus/d3plus/blob/fe174c3153bf379a226e4a41b6a8492a86c3a1b7/packages/format/src/formatDefaultLocale.ts#L8)
68
115
 
69
116
  An extension to d3's [formatDefaultLocale](https://github.com/d3/d3-format#api-reference) function that allows setting the locale globally for formatters.
70
117
 
118
+ #### Parameters
71
119
 
72
- This is a global function
120
+ | Parameter | Type | Description |
121
+ | ------ | ------ | ------ |
122
+ | `definition` | `FormatLocaleDefinition` | The localization definition. |
73
123
 
74
- ---
124
+ #### Returns
75
125
 
126
+ `Record`\<`string`, `unknown`\>
package/es/src/format.js CHANGED
@@ -1,11 +1,6 @@
1
1
  import abbreviate from "./formatAbbreviate.js";
2
2
  import { format } from "d3-format";
3
- /**
4
- @function format
5
- @desc An extension to d3's [format](https://github.com/d3/d3-format#api-reference) function that adds more string formatting types and localizations.
6
- @param {String} specifier The string specifier used by the format function.
7
- @returns {Function}
8
- */ export default function(specifier) {
3
+ export default function(specifier) {
9
4
  if (specifier === ".3~a") return abbreviate;
10
5
  return format(specifier);
11
- };
6
+ }
@@ -4,14 +4,14 @@ function _type_of(obj) {
4
4
  }
5
5
  import { formatLocale } from "d3-format";
6
6
  import { formatLocale as defaultLocale } from "@d3plus/locales";
7
- var round = function(x, n) {
8
- return parseFloat(Math.round(x * Math.pow(10, n)) / Math.pow(10, n)).toFixed(n);
7
+ var round = function round(x, n) {
8
+ return parseFloat((Math.round(x * Math.pow(10, n)) / Math.pow(10, n)).toString()).toFixed(n);
9
9
  };
10
10
  /**
11
11
  * @private
12
- */ function formatSuffix(str, precision, suffixes) {
12
+ */ function formatSuffix(str, precision, suffixes) {
13
13
  var i = 0;
14
- var value = parseFloat(str.replace("", "-"), 10);
14
+ var value = parseFloat(str.replace("\u2212", "-"));
15
15
  if (value) {
16
16
  if (value < 0) value *= -1;
17
17
  i = 1 + Math.floor(1e-12 + Math.log(value) / Math.LN10);
@@ -25,7 +25,7 @@ var round = function(x, n) {
25
25
  }
26
26
  /**
27
27
  * @private
28
- */ function parseSuffixes(d, i) {
28
+ */ function parseSuffixes(d, i) {
29
29
  var k = Math.pow(10, Math.abs(8 - i) * 3);
30
30
  return {
31
31
  scale: i > 8 ? function(d) {
@@ -37,14 +37,13 @@ var round = function(x, n) {
37
37
  };
38
38
  }
39
39
  /**
40
- @function formatAbbreviate
41
- @desc Formats a number to an appropriate number of decimal places and rounding, adding suffixes if applicable (ie. `1200000` to `"1.2M"`).
42
- @param {Number|String} n The number to be formatted.
43
- @param {Object|String} locale The locale config to be used. If *value* is an object, the function will format the numbers according the object. The object must include `suffixes`, `delimiter` and `currency` properties.
44
- @returns {String}
45
- */ export default function(n) {
46
- var locale = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "en-US", precision = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : undefined;
47
- if (isFinite(n)) n *= 1;
40
+ Formats a number to an appropriate number of decimal places and rounding, adding suffixes if applicable (ie. `1200000` to `"1.2M"`).
41
+ @param n The number to be formatted.
42
+ @param locale The locale config to be used. If an object is provided, the function will format the numbers according to the object. The object must include `suffixes`, `delimiter` and `currency` properties.
43
+ @param precision Number of significant digits to display.
44
+ */ export default function formatAbbreviate(n) {
45
+ var locale = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "en-US", precision = arguments.length > 2 ? arguments[2] : void 0;
46
+ if (isFinite(n)) n = n * 1;
48
47
  else return "N/A";
49
48
  var negative = n < 0;
50
49
  var length = n.toString().split(".")[0].replace("-", "").length, localeConfig = (typeof locale === "undefined" ? "undefined" : _type_of(locale)) === "object" ? locale : defaultLocale[locale] || defaultLocale["en-US"], suffixes = localeConfig.suffixes.map(parseSuffixes);
@@ -71,7 +70,7 @@ var round = function(x, n) {
71
70
  } else if (length === 3) val = d3plusFormatLocale.format(",f")(n);
72
71
  else if (n < 1 && n > -1) val = d3plusFormatLocale.format(".2g")(n);
73
72
  else val = d3plusFormatLocale.format(".3g")(n);
74
- return "".concat(negative && val.charAt(0) !== "" ? "" : "").concat(val).replace(/−/g, "-") // replace new d3 default minus sign () to hyphen-minus (-)
73
+ return "".concat(negative && val.charAt(0) !== "\u2212" ? "\u2212" : "").concat(val).replace(/\u2212/g, "-") // replace new d3 default minus sign (\u2212) to hyphen-minus (-)
75
74
  .replace(/(\.[0]*[1-9]*)[0]*$/g, "$1") // removes any trailing zeros
76
75
  .replace(/\.[0]*$/g, ""); // removes any trailing decimal point
77
76
  }
@@ -47,13 +47,11 @@ function _unsupported_iterable_to_array(o, minLen) {
47
47
  import { timeYear, timeMonth, timeHour, timeMinute, timeSecond } from "d3-time";
48
48
  import { timeFormat } from "d3-time-format";
49
49
  /**
50
- @function formatDate
51
- @desc A default set of date formatters, which takes into account both the interval in between in each data point but also the start/end data points.
52
- @param {Date} d The date string to be formatted.
53
- @param {Array} dataArray The full array of ordered Date Objects.
54
- @param {Function} [formatter = d3.timeFormat] An optional instance of d3.timeFormat to be used for localization.
55
- @returns {String}
56
- */ export default function(d, dataArray) {
50
+ A default set of date formatters, which takes into account both the interval in between in each data point but also the start/end data points.
51
+ @param d The date to format.
52
+ @param dataArray The full array of ordered Date Objects.
53
+ @param formatter Optional custom format string or function.
54
+ */ export default function formatDate(d, dataArray) {
57
55
  var formatter = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : timeFormat;
58
56
  var formatHour = formatter("%I %p"), formatMillisecond = formatter(".%L"), formatMinute = formatter("%I:%M"), formatMonth = formatter("%b"), formatMonthDay = formatter("%b %-d"), formatMonthDayYear = formatter("%b %-d, %Y"), formatMonthYear = formatter("%b %Y"), formatQuarter = formatter("Q%q"), formatQuarterYear = formatter("Q%q %Y"), formatSecond = formatter(":%S"), formatYear = formatter("%Y");
59
57
  var labelIndex = dataArray.findIndex(function(a) {
@@ -65,8 +63,8 @@ import { timeFormat } from "d3-time-format";
65
63
  if (i) {
66
64
  arr[0].push(d.getFullYear() - dataArray[i - 1].getFullYear());
67
65
  arr[1].push(monthDiff(dataArray[i - 1], d));
68
- arr[2].push(Math.round((d - dataArray[i - 1]) / (1000 * 60 * 60 * 24)));
69
- arr[3].push(Math.round((d - dataArray[i - 1]) / (1000 * 60 * 60)));
66
+ arr[2].push(Math.round((+d - +dataArray[i - 1]) / (1000 * 60 * 60 * 24)));
67
+ arr[3].push(Math.round((+d - +dataArray[i - 1]) / (1000 * 60 * 60)));
70
68
  }
71
69
  return arr;
72
70
  }, [
@@ -77,26 +75,26 @@ import { timeFormat } from "d3-time-format";
77
75
  ]), 4), yearlySteps = _dataArray_reduce[0], monthlySteps = _dataArray_reduce[1], dailySteps = _dataArray_reduce[2], hourlySteps = _dataArray_reduce[3];
78
76
  return (yearlySteps.every(function(s) {
79
77
  return s >= 1 && !(s % 1);
80
- }) // Yearly Data
78
+ }) // Yearly Data
81
79
  ? formatYear : monthlySteps.every(function(s) {
82
80
  return s >= 3 && !(s % 3);
83
81
  }) // Quarterly Data
84
- ? +timeYear(d) === d || firstOrLast || smallArray ? formatQuarterYear : formatQuarter : monthlySteps.every(function(s) {
82
+ ? +timeYear(d) === +d || firstOrLast || smallArray ? formatQuarterYear : formatQuarter : monthlySteps.every(function(s) {
85
83
  return s >= 1 && !(s % 1);
86
84
  }) // Monthly Data
87
- ? +timeYear(d) === d || firstOrLast || smallArray ? formatMonthYear : formatMonth : dailySteps.every(function(s) {
85
+ ? +timeYear(d) === +d || firstOrLast || smallArray ? formatMonthYear : formatMonth : dailySteps.every(function(s) {
88
86
  return s >= 1 && !(s % 1);
89
87
  }) // Daily Data
90
- ? +timeYear(d) === d || firstOrLast || smallArray ? formatMonthDayYear : formatMonthDay : hourlySteps.every(function(s) {
88
+ ? +timeYear(d) === +d || firstOrLast || smallArray ? formatMonthDayYear : formatMonthDay : hourlySteps.every(function(s) {
91
89
  return s >= 1 && !(s % 1);
92
90
  }) // Hourly Data
93
- ? firstOrLast || smallArray ? formatMonthDayYear : +timeMonth(d) === d ? formatMonthDay : formatHour : timeSecond(d) < d ? formatMillisecond : timeMinute(d) < d ? formatSecond : timeHour(d) < d ? formatMinute : d)(d);
91
+ ? firstOrLast || smallArray ? formatMonthDayYear : +timeMonth(d) === +d ? formatMonthDay : formatHour : timeSecond(d) < d ? formatMillisecond : timeMinute(d) < d ? formatSecond : timeHour(d) < d ? formatMinute : function(_d) {
92
+ return _d.toString();
93
+ })(d);
94
94
  }
95
95
  /**
96
- @function monthDiff
97
- @desc Returns the number of months between two Date objects
98
- @param {*} d1
99
- @param {*} d2
96
+ Returns the number of months between two Date objects
97
+
100
98
  @returns {Number} the number of months between the two Date objects
101
99
  @private
102
100
  */ function monthDiff(d1, d2) {
@@ -1,12 +1,10 @@
1
1
  import format from "./format.js";
2
2
  import { formatDefaultLocale } from "d3-format";
3
3
  /**
4
- @function formatDefaultLocale
5
- @desc An extension to d3's [formatDefaultLocale](https://github.com/d3/d3-format#api-reference) function that allows setting the locale globally for formatters.
6
- @param {Object} definition The localization definition.
7
- @returns {Object}
4
+ An extension to d3's [formatDefaultLocale](https://github.com/d3/d3-format#api-reference) function that allows setting the locale globally for formatters.
5
+ @param definition The localization definition.
8
6
  */ export default function(definition) {
9
7
  var locale = formatDefaultLocale(definition);
10
8
  locale.format = format;
11
9
  return locale;
12
- };
10
+ }
package/package.json CHANGED
@@ -1,18 +1,25 @@
1
1
  {
2
2
  "name": "@d3plus/format",
3
- "version": "3.0.16",
3
+ "version": "3.1.1",
4
4
  "description": "JavaScript formatters for localized numbers and dates.",
5
5
  "license": "MIT",
6
6
  "type": "module",
7
- "exports": "./es/index.js",
7
+ "types": "./types/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./types/index.d.ts",
11
+ "default": "./es/index.js"
12
+ }
13
+ },
8
14
  "browser": "./umd/d3plus-format.full.js",
9
15
  "engines": {
10
- "node": ">=18"
16
+ "node": ">=20"
11
17
  },
12
18
  "sideEffects": false,
13
19
  "files": [
14
20
  "umd",
15
- "es"
21
+ "es",
22
+ "types"
16
23
  ],
17
24
  "homepage": "https://d3plus.org",
18
25
  "repository": {
@@ -27,16 +34,18 @@
27
34
  "data",
28
35
  "visualization"
29
36
  ],
37
+ "dependencies": {
38
+ "d3-format": "^3.1.0",
39
+ "d3-time": "^3.1.0",
40
+ "d3-time-format": "^4.1.0",
41
+ "@d3plus/locales": "3.1.1"
42
+ },
30
43
  "scripts": {
31
44
  "build:esm": "node ../../scripts/build-esm.js",
45
+ "build:types": "tsc",
32
46
  "build:umd": "node ../../scripts/build-umd.js",
33
47
  "dev": "node ../../scripts/dev.js",
34
- "test": "eslint index.js src/**/*.js && eslint --global=it test && mocha 'test/**/*-test.js'"
35
- },
36
- "dependencies": {
37
- "@d3plus/locales": "3.0.16",
38
- "d3-format": "^3.1.0",
39
- "d3-time": "^3.1.0",
40
- "d3-time-format": "^4.1.0"
48
+ "test": "eslint index.ts src/**/*.ts && eslint --global=it test && mocha 'test/**/*-test.js'",
49
+ "test:coverage": "c8 -r text -r lcov --src src mocha 'test/**/*-test.js'"
41
50
  }
42
51
  }
@@ -0,0 +1,4 @@
1
+ export { default as format } from "./src/format.js";
2
+ export { default as formatDefaultLocale } from "./src/formatDefaultLocale.js";
3
+ export { default as formatAbbreviate } from "./src/formatAbbreviate.js";
4
+ export { default as formatDate } from "./src/formatDate.js";
@@ -0,0 +1,9 @@
1
+ /**
2
+ An extension to d3's [format](https://github.com/d3/d3-format#api-reference) function that adds more string formatting types and localizations.
3
+ @param specifier The string specifier used by the format function.
4
+ */
5
+ type Formatter = (n: number | string | {
6
+ valueOf(): number;
7
+ }) => string;
8
+ export default function (specifier: string): Formatter;
9
+ export {};
@@ -0,0 +1,8 @@
1
+ import type { FormatLocaleDefinition } from "@d3plus/locales";
2
+ /**
3
+ Formats a number to an appropriate number of decimal places and rounding, adding suffixes if applicable (ie. `1200000` to `"1.2M"`).
4
+ @param n The number to be formatted.
5
+ @param locale The locale config to be used. If an object is provided, the function will format the numbers according to the object. The object must include `suffixes`, `delimiter` and `currency` properties.
6
+ @param precision Number of significant digits to display.
7
+ */
8
+ export default function formatAbbreviate(n: number | string, locale?: string | FormatLocaleDefinition, precision?: string): string;
@@ -0,0 +1,9 @@
1
+ type DateFormatter = (specifier: string) => (date: Date) => string;
2
+ /**
3
+ A default set of date formatters, which takes into account both the interval in between in each data point but also the start/end data points.
4
+ @param d The date to format.
5
+ @param dataArray The full array of ordered Date Objects.
6
+ @param formatter Optional custom format string or function.
7
+ */
8
+ export default function formatDate(d: Date, dataArray: Date[], formatter?: DateFormatter): string;
9
+ export {};
@@ -0,0 +1,6 @@
1
+ import { formatDefaultLocale } from "d3-format";
2
+ /**
3
+ An extension to d3's [formatDefaultLocale](https://github.com/d3/d3-format#api-reference) function that allows setting the locale globally for formatters.
4
+ @param definition The localization definition.
5
+ */
6
+ export default function (definition: Parameters<typeof formatDefaultLocale>[0]): Record<string, unknown>;