<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@easyops-cn/brick-next-pipes](./brick-next-pipes.md) &gt; [unitFormat](./brick-next-pipes.unitformat.md)

## unitFormat() function

将一个数值转换为带单位的数据。

 Others

**Signature:**

```typescript
export declare function unitFormat(value: number, unit: string, precision?: number, targetUnit?: string, fixedPrecision?: boolean): [string, string];
```

## Parameters

|  Parameter | Type | Description |
|  --- | --- | --- |
|  value | number | 数值。 |
|  unit | string | 当前单位。 |
|  precision | number | 精度（默认为 <code>2</code>）。 |
|  targetUnit | string | 目标单位，若不填则会自动计算。 |
|  fixedPrecision | boolean |  |

**Returns:**

\[string, string\]

由转换后的数值和单位组成的数组。

## Example


```ts
unitFormat(1024, "KBps")
// Returns `["1.00", "MBps"]`
```


