File tree 2 files changed +19
-9
lines changed
2 files changed +19
-9
lines changed Original file line number Diff line number Diff line change @@ -34,3 +34,17 @@ export function useKiloBytesNumberFormat(
34
34
unit : 'kilobyte' ,
35
35
} )
36
36
}
37
+
38
+ export function useKiloBytesPerSecondNumberFormat (
39
+ value : MaybeRef < number | string > | ComputedRef < number | string > ,
40
+ options ?: {
41
+ locales ?: Intl . LocalesArgument
42
+ } & Intl . NumberFormatOptions ,
43
+ ) {
44
+ return useNumberFormat ( value , {
45
+ ...options ,
46
+ style : 'unit' ,
47
+ unit : 'kilobyte-per-second' ,
48
+ unitDisplay : 'short' ,
49
+ } )
50
+ }
Original file line number Diff line number Diff line change 1
1
import type { ComputedRef , Ref } from 'vue'
2
2
import { computed , ref } from 'vue'
3
3
4
+ import { useKiloBytesPerSecondNumberFormat } from './intlNumberFormat'
5
+
4
6
interface TimeSeriesOptions {
5
7
type : 'counter' | 'gauge'
6
8
interval : number
@@ -126,16 +128,10 @@ export function useBytesRate(
126
128
lastUpdateTime . value = now
127
129
} )
128
130
129
- const kiloBytesFormatter = new Intl . NumberFormat ( 'en-US' , {
130
- style : 'unit' ,
131
- unit : 'kilobyte-per-second' ,
132
- unitDisplay : 'short' ,
133
- } )
134
-
135
- const formatted = computed ( ( ) => {
131
+ const formatted = useKiloBytesPerSecondNumberFormat ( computed ( ( ) => {
136
132
const kiloBytesPerSecond = bytesRate . value / 1024
137
- return kiloBytesFormatter . format ( Number . parseFloat ( kiloBytesPerSecond . toFixed ( 2 ) ) )
138
- } )
133
+ return Number . parseFloat ( kiloBytesPerSecond . toFixed ( 2 ) )
134
+ } ) )
139
135
140
136
return {
141
137
bytesRate,
You can’t perform that action at this time.
0 commit comments