Skip to content

Commit

Permalink
fix(utils): use export & fix formatValueToMinUnit type
Browse files Browse the repository at this point in the history
  • Loading branch information
0721Betty committed Mar 25, 2024
1 parent c9c626f commit 7cdae17
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion packages/utils/lib/__test__/useBatchSettings.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { describe, it, expect, vi } from 'vitest'
import useBatchSettings from '../useBatchSettings'
import { useBatchSettings } from '../useBatchSettings'

describe('useBatchSettings', () => {
const {
Expand Down
4 changes: 2 additions & 2 deletions packages/utils/lib/format.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ enum SizeOrTimeUnit {
MB = 1024 * 1024,
GB = 1024 * 1024 * 1024,
}
export const formatValueToMinUnit = (value: number, unit: keyof typeof SizeOrTimeUnit) => {
export const formatValueToMinUnit = (value: number, unit: string) => {
if (!(unit in SizeOrTimeUnit)) {
throw new Error(`Invalid unit: ${unit}`)
}
return value * SizeOrTimeUnit[unit]
return value * SizeOrTimeUnit[unit as keyof typeof SizeOrTimeUnit]
}
2 changes: 1 addition & 1 deletion packages/utils/lib/useBatchSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ enum BatchSettingTypes {
InfluxDB = 'influxdb',
}

export default (locale: 'zh' | 'en' = 'en') => {
export const useBatchSettings = (locale: 'zh' | 'en' = 'en') => {
const i18n = createI18n({
locale,
messages: {
Expand Down

0 comments on commit 7cdae17

Please sign in to comment.