API Reference > @easyops-cn/brick-next-pipes > unitFormat
unitFormat() function
将一个数值转换为带单位的数据。
Others
Signature:
export declare function unitFormat(
value: number,
unit: string,
precision?: number
): [string, string];
Parameters
| Parameter | Type | Description |
|---|---|---|
| value | number | 数值。 |
| unit | string | 单位。 |
| precision | number | 精度(默认为 2)。 |
Returns:
[string, string]
由转换后的数值和单位组成的数组。
Example
unitFormat(1024, "KBps");
// Returns `["1.00", "MBps"]`