@dynatrace-sdk/units
Advanced tools
Comparing version 0.11.1 to 0.12.0
@@ -5,2 +5,15 @@ # Units | ||
## 0.12.0 | ||
### Minor Changes | ||
- BREAKING CHANGE: Changing the default settings to interpret bytes and bits in the decimal system. | ||
- Expose useGrouping option to format function | ||
### Patch Changes | ||
- Add support for non-convertible variants. | ||
- Fix bug where Bel and ratio are treated as variants. | ||
- Fix a bug where cascading inside the format function caused problems with rounded values | ||
## 0.11.1 | ||
@@ -7,0 +20,0 @@ |
@@ -10,3 +10,3 @@ --- | ||
import NpmLogo from '@site/static/img/npm-logo.png'; | ||
import NpmLogo from "@site/static/img/npm-logo.png"; | ||
@@ -20,4 +20,6 @@ <div class="row margin-bottom--md"> | ||
</div> | ||
<div class="col" style={{textAlign: 'right'}}> | ||
<a href="https://www.npmjs.com/package/@dynatrace-sdk/units/v/0.11.1">v0.11.1</a> | ||
<div class="col" style={{ textAlign: "right" }}> | ||
<a href="https://www.npmjs.com/package/@dynatrace-sdk/units/v/0.12.0"> | ||
v0.12.0 | ||
</a> | ||
</div> | ||
@@ -59,7 +61,8 @@ </div> | ||
| Name | Type | Description | | ||
| --------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------- | | ||
| locale | <a href="https://developer.mozilla.org/en-US/docs/Glossary/String">string</a> | Array<<a href="https://developer.mozilla.org/en-US/docs/Glossary/String">string</a>> | The locale according to which the number will abbreviate. | | ||
| maximumFractionDigits | <a href="https://developer.mozilla.org/en-US/docs/Glossary/Number">number</a> | Maximum number of decimal places. | | ||
| minimumFractionDigits | <a href="https://developer.mozilla.org/en-US/docs/Glossary/Number">number</a> | Minimum number of decimal places. | | ||
| Name | Type | Description | | ||
| --------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------- | | ||
| locale | <a href="https://developer.mozilla.org/en-US/docs/Glossary/String">string</a> | Array<<a href="https://developer.mozilla.org/en-US/docs/Glossary/String">string</a>> | The locale according to which the number will abbreviate. | | ||
| maximumFractionDigits | <a href="https://developer.mozilla.org/en-US/docs/Glossary/Number">number</a> | Maximum number of decimal places. | | ||
| minimumFractionDigits | <a href="https://developer.mozilla.org/en-US/docs/Glossary/Number">number</a> | Minimum number of decimal places. | | ||
| useGrouping | <a href="https://developer.mozilla.org/en-US/docs/Glossary/Boolean">boolean</a> | Whether to use grouping separators, such as thousands separators or thousand/lakh/crore separators | | ||
@@ -72,7 +75,8 @@ ### AdjustFractionDigitsOptions | ||
| Name | Type | Description | | ||
| --------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------- | | ||
| locale | <a href="https://developer.mozilla.org/en-US/docs/Glossary/String">string</a> | Array<<a href="https://developer.mozilla.org/en-US/docs/Glossary/String">string</a>> | The locale according to which the number will be adjusted. | | ||
| maximumFractionDigits | <a href="https://developer.mozilla.org/en-US/docs/Glossary/Number">number</a> | Maximum number of decimal places. | | ||
| minimumFractionDigits | <a href="https://developer.mozilla.org/en-US/docs/Glossary/Number">number</a> | Minimum number of decimal places. | | ||
| Name | Type | Description | | ||
| --------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------- | | ||
| locale | <a href="https://developer.mozilla.org/en-US/docs/Glossary/String">string</a> | Array<<a href="https://developer.mozilla.org/en-US/docs/Glossary/String">string</a>> | The locale according to which the number will be adjusted. | | ||
| maximumFractionDigits | <a href="https://developer.mozilla.org/en-US/docs/Glossary/Number">number</a> | Maximum number of decimal places. | | ||
| minimumFractionDigits | <a href="https://developer.mozilla.org/en-US/docs/Glossary/Number">number</a> | Minimum number of decimal places. | | ||
| useGrouping | <a href="https://developer.mozilla.org/en-US/docs/Glossary/Boolean">boolean</a> | Whether to use grouping separators, such as thousands separators or thousand/lakh/crore separators | | ||
@@ -118,12 +122,13 @@ ### FormatDateOptions | ||
| Name | Type | Description | | ||
| --------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | ||
| abbreviate | <a href="https://developer.mozilla.org/en-US/docs/Glossary/Boolean">boolean</a> | <p>It will shorten the number to a shorter format. (e.g. <code>input: 1500, output: 1.5k</code>).</p> | | ||
| cascade | <a href="https://developer.mozilla.org/en-US/docs/Glossary/Number">number</a> | <p>Will search for the biggest unit within its group and cascade it down the the specified dept. The last number will get rounded to <code>maximumFractionDigits</code>. (e.g. <code>format(1500, { input: units.length.meter, cascade: 2}), output: "1 km 500 m")</code>).</p> | | ||
| input | FromUnit | <p>If input unit is defined, it will convert it to the best fitting unit. (e.g. <code>format(1500, { input: units.length.meter }), output: "1.5 km")</code>).</p> | | ||
| locale | <a href="https://developer.mozilla.org/en-US/docs/Glossary/String">string</a> | Array<<a href="https://developer.mozilla.org/en-US/docs/Glossary/String">string</a>> | <p>The locale that will be used to format the number. By default it will use the platform locale specified by the user.</p> | | ||
| maximumFractionDigits | <a href="https://developer.mozilla.org/en-US/docs/Glossary/Number">number</a> | <p>The amount of maximumFractionDigits points. See <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#maximumfractiondigits">MDN</a>.</p> | | ||
| minimumFractionDigits | <a href="https://developer.mozilla.org/en-US/docs/Glossary/Number">number</a> | <p>The amount of minimumFractionDigits points. See <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#minimumfractiondigits">MDN</a>.</p> | | ||
| output | OutputUnit<UndefinedCoalescing<FromUnit | > | ToUnit> | <p>If not specified, the conversion is disabled (e.g. <code>format(1500), output: 1.5K</code>).</p> | | ||
| suffix | <a href="https://developer.mozilla.org/en-US/docs/Glossary/String">string</a> | A custom suffix that overwrites the unit symbol. | | ||
| Name | Type | Description | | ||
| --------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | ||
| abbreviate | <a href="https://developer.mozilla.org/en-US/docs/Glossary/Boolean">boolean</a> | <p>It will shorten the number to a shorter format. (e.g. <code>input: 1500, output: 1.5k</code>).</p> | | ||
| cascade | <a href="https://developer.mozilla.org/en-US/docs/Glossary/Number">number</a> | <p>Will search for the biggest unit within its group and cascade it down the the specified dept. The last number will get rounded to <code>maximumFractionDigits</code>. (e.g. <code>format(1500, { input: units.length.meter, cascade: 2}), output: "1 km 500 m")</code>).</p> | | ||
| input | FromUnit | <p>If input unit is defined, it will convert it to the best fitting unit. (e.g. <code>format(1500, { input: units.length.meter }), output: "1.5 km")</code>).</p> | | ||
| locale | <a href="https://developer.mozilla.org/en-US/docs/Glossary/String">string</a> | Array<<a href="https://developer.mozilla.org/en-US/docs/Glossary/String">string</a>> | <p>The locale that will be used to format the number. By default it will use the platform locale specified by the user.</p> | | ||
| maximumFractionDigits | <a href="https://developer.mozilla.org/en-US/docs/Glossary/Number">number</a> | <p>The amount of maximumFractionDigits points. See <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#maximumfractiondigits">MDN</a>. If minimumFractionDigits is passed, set to minimumFractionDigits by default. Otherwise set to 0 by default.</p> | | ||
| minimumFractionDigits | <a href="https://developer.mozilla.org/en-US/docs/Glossary/Number">number</a> | <p>The amount of minimumFractionDigits points. See <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#minimumfractiondigits">MDN</a>.</p> | | ||
| output | OutputUnit<UndefinedCoalescing<FromUnit | > | ToUnit> | <p>If not specified, the conversion is disabled (e.g. <code>format(1500), output: 1.5K</code>).</p> | | ||
| suffix | <a href="https://developer.mozilla.org/en-US/docs/Glossary/String">string</a> | A custom suffix that overwrites the unit symbol. | | ||
| useGrouping | <a href="https://developer.mozilla.org/en-US/docs/Glossary/Boolean">boolean</a> | <p>Whether to use grouping separators, such as thousands separators or thousand/lakh/crore separators See <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#usegrouping">MDN</a></p> | | ||
@@ -198,3 +203,3 @@ ## Variables | ||
<!-- no returns --> | ||
{/* no returns */} | ||
@@ -318,3 +323,3 @@ </div> | ||
<!-- no returns --> | ||
{/* no returns */} | ||
@@ -369,3 +374,3 @@ </div> | ||
<!-- no returns --> | ||
{/* no returns */} | ||
@@ -391,3 +396,3 @@ </div> | ||
<!-- no returns --> | ||
{/* no returns */} | ||
@@ -413,3 +418,3 @@ </div> | ||
<!-- no returns --> | ||
{/* no returns */} | ||
@@ -421,3 +426,4 @@ </div> | ||
<div class="padding-bottom--md"> | ||
All supported convertible units. For more details see a <a href="#conversion-example">conversion example</a>. | ||
All supported convertible units. For more details see a{" "} | ||
<a href="#conversion-example">conversion example</a>. | ||
</div> | ||
@@ -434,3 +440,4 @@ | ||
<div class="padding-bottom--md"> | ||
A type for every <a href="#convertibleunit">convertible unit</a>. For more details see a <a href="#conversion-example">conversion example</a>. | ||
A type for every <a href="#convertibleunit">convertible unit</a>. For more | ||
details see a <a href="#conversion-example">conversion example</a>. | ||
</div> | ||
@@ -441,3 +448,4 @@ | ||
<div class="padding-bottom--md"> | ||
All units to which the `FromUnit` can be converted. For more details see a <a href="#conversion-example">conversion example</a>. | ||
All units to which the `FromUnit` can be converted. For more details see a{" "} | ||
<a href="#conversion-example">conversion example</a>. | ||
</div> | ||
@@ -448,3 +456,3 @@ | ||
<div class="padding-bottom--md"> | ||
A unit that is supported by our formatting functionality. | ||
A unit that is supported by our formatting functionality. | ||
</div> | ||
@@ -451,0 +459,0 @@ |
{ | ||
"name": "@dynatrace-sdk/units", | ||
"version": "0.11.1", | ||
"version": "0.12.0", | ||
"license": "Apache-2.0", | ||
@@ -5,0 +5,0 @@ "description": "Tools for converting and formatting the units and numerical values.", |
@@ -46,3 +46,3 @@ export declare const properties: { | ||
readonly newton: import("./types").UnitProperties<"force">; | ||
readonly bel: import("./types").UnitProperties<"ratio">; | ||
readonly bel: import("./types").UnitProperties<"log_ratio">; | ||
readonly bar: import("./types").UnitProperties<"pressure">; | ||
@@ -49,0 +49,0 @@ readonly psi: import("./types").UnitProperties<"pressure">; |
@@ -5,2 +5,3 @@ import { Unit } from './types'; | ||
declare type VariantUnits<U extends Unit> = Unit[]; | ||
export declare function isConvertibleUnit(unit: Unit): boolean; | ||
export declare function variants<U extends Unit>(unit: U): Variants<U>[]; | ||
@@ -7,0 +8,0 @@ /** |
@@ -38,2 +38,4 @@ /** Units of exponential numbers, i.e. kilo, million, ect. */ | ||
locale?: string | string[]; | ||
/** Whether to use grouping separators, such as thousands separators or thousand/lakh/crore separators */ | ||
useGrouping?: boolean; | ||
} | ||
@@ -40,0 +42,0 @@ export declare const defaultAbbreviateOptions: { |
@@ -8,2 +8,4 @@ export interface AdjustFractionDigitsOptions { | ||
locale?: string | string[]; | ||
/** Whether to use grouping separators, such as thousands separators or thousand/lakh/crore separators */ | ||
useGrouping?: boolean; | ||
} | ||
@@ -10,0 +12,0 @@ /** |
@@ -55,2 +55,3 @@ import type { Unit, FormattableUnit, ConvertibleUnit, OutputUnit, FormattablePack, UndefinedCoalescing } from '../util-convert/types'; | ||
* See [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#maximumfractiondigits). | ||
* If minimumFractionDigits is passed, set to minimumFractionDigits by default. Otherwise set to 0 by default. | ||
*/ | ||
@@ -64,2 +65,7 @@ maximumFractionDigits?: number; | ||
/** | ||
* Whether to use grouping separators, such as thousands separators or thousand/lakh/crore separators | ||
* See [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#usegrouping) | ||
*/ | ||
useGrouping?: boolean; | ||
/** | ||
* It will shorten the number to a shorter format. | ||
@@ -66,0 +72,0 @@ * (e.g. `input: 1500, output: 1.5k`). |
export declare const units: { | ||
readonly quettabyte: [Readonly<{ | ||
group: "byte_m"; | ||
index: 10; | ||
exponent: 1; | ||
}>]; | ||
readonly ronnabyte: [Readonly<{ | ||
group: "byte_m"; | ||
index: 9; | ||
exponent: 1; | ||
}>]; | ||
readonly yottabyte: [Readonly<{ | ||
group: "byte_m"; | ||
index: 8; | ||
exponent: 1; | ||
}>]; | ||
readonly zettabyte: [Readonly<{ | ||
group: "byte_m"; | ||
index: 7; | ||
exponent: 1; | ||
}>]; | ||
readonly exabyte: [Readonly<{ | ||
group: "byte_m"; | ||
index: 6; | ||
exponent: 1; | ||
}>]; | ||
readonly petabyte: [Readonly<{ | ||
group: "byte_m"; | ||
index: 5; | ||
exponent: 1; | ||
}>]; | ||
readonly terabyte: [Readonly<{ | ||
group: "byte_m"; | ||
index: 4; | ||
exponent: 1; | ||
}>]; | ||
readonly gigabyte: [Readonly<{ | ||
group: "byte_m"; | ||
index: 3; | ||
exponent: 1; | ||
}>]; | ||
readonly megabyte: [Readonly<{ | ||
group: "byte_m"; | ||
index: 2; | ||
exponent: 1; | ||
}>]; | ||
readonly kilobyte: [Readonly<{ | ||
group: "byte_m"; | ||
index: 1; | ||
exponent: 1; | ||
}>]; | ||
readonly byte: [Readonly<{ | ||
group: "byte_m"; | ||
index: 0; | ||
exponent: 1; | ||
}>]; | ||
readonly quebibyte: [Readonly<{ | ||
@@ -52,57 +107,57 @@ group: "byte_b"; | ||
}>]; | ||
readonly byte: [Readonly<{ | ||
group: "byte_b"; | ||
index: 0; | ||
exponent: 1; | ||
}>]; | ||
readonly quettabyte: [Readonly<{ | ||
group: "byte_m"; | ||
readonly quettabit: [Readonly<{ | ||
group: "bit_m"; | ||
index: 10; | ||
exponent: 1; | ||
}>]; | ||
readonly ronnabyte: [Readonly<{ | ||
group: "byte_m"; | ||
readonly ronnabit: [Readonly<{ | ||
group: "bit_m"; | ||
index: 9; | ||
exponent: 1; | ||
}>]; | ||
readonly yottabyte: [Readonly<{ | ||
group: "byte_m"; | ||
readonly yottabit: [Readonly<{ | ||
group: "bit_m"; | ||
index: 8; | ||
exponent: 1; | ||
}>]; | ||
readonly zettabyte: [Readonly<{ | ||
group: "byte_m"; | ||
readonly zettabit: [Readonly<{ | ||
group: "bit_m"; | ||
index: 7; | ||
exponent: 1; | ||
}>]; | ||
readonly exabyte: [Readonly<{ | ||
group: "byte_m"; | ||
readonly exabit: [Readonly<{ | ||
group: "bit_m"; | ||
index: 6; | ||
exponent: 1; | ||
}>]; | ||
readonly petabyte: [Readonly<{ | ||
group: "byte_m"; | ||
readonly petabit: [Readonly<{ | ||
group: "bit_m"; | ||
index: 5; | ||
exponent: 1; | ||
}>]; | ||
readonly terabyte: [Readonly<{ | ||
group: "byte_m"; | ||
readonly terabit: [Readonly<{ | ||
group: "bit_m"; | ||
index: 4; | ||
exponent: 1; | ||
}>]; | ||
readonly gigabyte: [Readonly<{ | ||
group: "byte_m"; | ||
readonly gigabit: [Readonly<{ | ||
group: "bit_m"; | ||
index: 3; | ||
exponent: 1; | ||
}>]; | ||
readonly megabyte: [Readonly<{ | ||
group: "byte_m"; | ||
readonly megabit: [Readonly<{ | ||
group: "bit_m"; | ||
index: 2; | ||
exponent: 1; | ||
}>]; | ||
readonly kilobyte: [Readonly<{ | ||
group: "byte_m"; | ||
readonly kilobit: [Readonly<{ | ||
group: "bit_m"; | ||
index: 1; | ||
exponent: 1; | ||
}>]; | ||
readonly bit: [Readonly<{ | ||
group: "bit_m"; | ||
index: 0; | ||
exponent: 1; | ||
}>]; | ||
readonly quebibit: [Readonly<{ | ||
@@ -158,57 +213,2 @@ group: "bit_b"; | ||
}>]; | ||
readonly bit: [Readonly<{ | ||
group: "bit_b"; | ||
index: 0; | ||
exponent: 1; | ||
}>]; | ||
readonly quettabit: [Readonly<{ | ||
group: "bit_m"; | ||
index: 10; | ||
exponent: 1; | ||
}>]; | ||
readonly ronnabit: [Readonly<{ | ||
group: "bit_m"; | ||
index: 9; | ||
exponent: 1; | ||
}>]; | ||
readonly yottabit: [Readonly<{ | ||
group: "bit_m"; | ||
index: 8; | ||
exponent: 1; | ||
}>]; | ||
readonly zettabit: [Readonly<{ | ||
group: "bit_m"; | ||
index: 7; | ||
exponent: 1; | ||
}>]; | ||
readonly exabit: [Readonly<{ | ||
group: "bit_m"; | ||
index: 6; | ||
exponent: 1; | ||
}>]; | ||
readonly petabit: [Readonly<{ | ||
group: "bit_m"; | ||
index: 5; | ||
exponent: 1; | ||
}>]; | ||
readonly terabit: [Readonly<{ | ||
group: "bit_m"; | ||
index: 4; | ||
exponent: 1; | ||
}>]; | ||
readonly gigabit: [Readonly<{ | ||
group: "bit_m"; | ||
index: 3; | ||
exponent: 1; | ||
}>]; | ||
readonly megabit: [Readonly<{ | ||
group: "bit_m"; | ||
index: 2; | ||
exponent: 1; | ||
}>]; | ||
readonly kilobit: [Readonly<{ | ||
group: "bit_m"; | ||
index: 1; | ||
exponent: 1; | ||
}>]; | ||
}; |
export declare const units: { | ||
readonly bitps: [Readonly<{ | ||
group: "bit_b"; | ||
group: "bit_m"; | ||
index: 0; | ||
@@ -12,3 +12,3 @@ exponent: 1; | ||
readonly bitpm: [Readonly<{ | ||
group: "bit_b"; | ||
group: "bit_m"; | ||
index: 0; | ||
@@ -22,3 +22,3 @@ exponent: 1; | ||
readonly bitph: [Readonly<{ | ||
group: "bit_b"; | ||
group: "bit_m"; | ||
index: 0; | ||
@@ -32,3 +32,3 @@ exponent: 1; | ||
readonly Bps: [Readonly<{ | ||
group: "byte_b"; | ||
group: "byte_m"; | ||
index: 0; | ||
@@ -42,3 +42,3 @@ exponent: 1; | ||
readonly Bpm: [Readonly<{ | ||
group: "byte_b"; | ||
group: "byte_m"; | ||
index: 0; | ||
@@ -52,3 +52,3 @@ exponent: 1; | ||
readonly Bph: [Readonly<{ | ||
group: "byte_b"; | ||
group: "byte_m"; | ||
index: 0; | ||
@@ -55,0 +55,0 @@ exponent: 1; |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
747044
24505