@dynatrace-sdk/units
Advanced tools
Comparing version 0.16.1 to 0.16.3
@@ -5,2 +5,14 @@ # Units | ||
## 0.16.3 | ||
### Patch Changes | ||
- Fix cascading overflow error | ||
## 0.16.2 | ||
### Patch Changes | ||
- parseTimeAsTimeValue() supports valid iso 8601 strings without hours, minutes, seconds or milliseconds. | ||
## 0.16.1 | ||
@@ -7,0 +19,0 @@ |
@@ -18,3 +18,3 @@ --- | ||
<div class="col" style={{textAlign: 'right'}}> | ||
<a href="https://www.npmjs.com/package/@dynatrace-sdk/units/v/0.16.1" target="_blank" rel="noopener noreferrer">v0.16.1</a> | ||
<a href="https://www.npmjs.com/package/@dynatrace-sdk/units/v/0.16.3" target="_blank" rel="noopener noreferrer">v0.16.3</a> | ||
</div> | ||
@@ -176,3 +176,3 @@ </div> | ||
<div class="padding-bottom--md"> | ||
<strong>_cascade(number,unit,depth,list?): ValueUnitList</strong> | ||
<strong>_cascade(number,unit,depth,list?,fractionDigits?): ValueUnitList</strong> | ||
@@ -224,2 +224,3 @@ <div class="padding-left--md"> | ||
|list|CascadeUnit| | ||
|fractionDigits|[number](https://developer.mozilla.org/en-US/docs/Glossary/Number)| | ||
@@ -284,3 +285,3 @@ | ||
import { abbreviateNumber } from '@dynatrace-sdk/units'; | ||
abbreviateNumber(1500) // '1.5K' | ||
abbreviateNumber(1500) // {"formattedValue": "2", "postfix": "k"} | ||
``` | ||
@@ -298,3 +299,3 @@ | ||
|input<sup>*required</sup>|[number](https://developer.mozilla.org/en-US/docs/Glossary/Number)|Number to be abbreviated. | | ||
|scale<sup>*required</sup>|Scale|<p>Scale to use for the abbreviation. Default is the decimal scale:</p> <ul> <li><code>abbreviateNumber(1_000) // '1K'</code></li> <li><code>abbreviateNumber(1_000_000) // '1M'</code></li> </ul> | | ||
|scale<sup>*required</sup>|Scale|<p>Scale to use for the abbreviation. Default is the decimal scale:</p> <ul> <li><code>abbreviateNumber(1_000) // {"formattedValue": "1", "postfix": "k"}</code></li> <li><code>abbreviateNumber(1_000_000, ExponentialOctalByteLevels) // {"formattedValue": "977", "postfix": "KiB"}</code></li> </ul> | | ||
|options<sup>*required</sup>|[AdjustFractionDigitsOptions](#adjustfractiondigitsoptions)| | | ||
@@ -341,3 +342,5 @@ | ||
The formatted number as a string. | ||
| Description | | ||
|---| | ||
|The formatted number as a string.| | ||
@@ -385,3 +388,5 @@ | ||
The result of the conversion (e.g. `1.5`). | ||
| Description | | ||
|---| | ||
|The result of the conversion (e.g. `1.5`).| | ||
@@ -424,3 +429,5 @@ | ||
A string containing the formatted number. | ||
| Description | | ||
|---| | ||
|A string containing the formatted number.| | ||
@@ -463,3 +470,5 @@ | ||
Date string | ||
| Description | | ||
|---| | ||
|Date string| | ||
@@ -535,3 +544,5 @@ | ||
An Array of parts containing the formatting result object. | ||
| Description | | ||
|---| | ||
|An Array of parts containing the formatting result object.| | ||
@@ -538,0 +549,0 @@ |
{ | ||
"name": "@dynatrace-sdk/units", | ||
"version": "0.16.1", | ||
"version": "0.16.3", | ||
"license": "Apache-2.0", | ||
@@ -5,0 +5,0 @@ "description": "Package for converting and formatting units and numerical values.", |
@@ -1,2 +0,2 @@ | ||
import { ConvertibleUnit, ValueUnitList } from './types'; | ||
import { ConvertibleUnit, ValueUnitList, OptionalValueUnitList } from './types'; | ||
type CascadeUnit = ((exponent: number) => ConvertibleUnit)[]; | ||
@@ -40,3 +40,10 @@ /** | ||
*/ | ||
export declare function cascade(number: number, unit: ConvertibleUnit, depth: number, list?: CascadeUnit): ValueUnitList; | ||
export declare function cascade(number: number, unit: ConvertibleUnit, depth: number, list?: CascadeUnit, fractionDigits?: number): ValueUnitList; | ||
/** Corrects overflow errors, by rounding and calculating if the unit value fits into next unit. | ||
* This error happens due to cascade calculations where the float precision leads to an inaccurate result where parts are falsely carried over to the next unit */ | ||
export declare function correctOverflow(list: OptionalValueUnitList, precision: number): ValueUnitList; | ||
/** | ||
* Merges values of units to a complete ConvertibleUnit list | ||
*/ | ||
export declare function addValuesToUnitList(list: CascadeUnit, valueList: ValueUnitList, exponent: number): OptionalValueUnitList; | ||
export {}; |
@@ -75,2 +75,6 @@ import { properties } from './properties'; | ||
export type ValueUnitList = ValueUnit[]; | ||
export type OptionalValueUnitList = { | ||
value?: number; | ||
unit: ConvertibleUnit; | ||
}[]; | ||
export type ArrayLength<A> = A extends { | ||
@@ -77,0 +81,0 @@ length: infer L; |
@@ -34,3 +34,3 @@ import { AdjustFractionDigitsOptions } from './adjust-maximum-fraction-digits'; | ||
* import { abbreviateNumber } from '@dynatrace-sdk/units'; | ||
* abbreviateNumber(1500) // '1.5K' | ||
* abbreviateNumber(1500) // {"formattedValue": "2", "postfix": "k"} | ||
* ``` | ||
@@ -44,4 +44,4 @@ */ | ||
* Default is the decimal scale: | ||
* - `abbreviateNumber(1_000) // '1K'` | ||
* - `abbreviateNumber(1_000_000) // '1M'` | ||
* - `abbreviateNumber(1_000) // {"formattedValue": "1", "postfix": "k"}` | ||
* - `abbreviateNumber(1_000_000, ExponentialOctalByteLevels) // {"formattedValue": "977", "postfix": "KiB"}` | ||
*/ | ||
@@ -48,0 +48,0 @@ scale?: Scale, options?: AdjustFractionDigitsOptions): { |
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
720553
25041