Skip to main content
Version: 2.x

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

ParameterTypeDescription
valuenumber数值。
unitstring单位。
precisionnumber精度(默认为 2)。

Returns:

[string, string]

由转换后的数值和单位组成的数组。

Example

unitFormat(1024, "KBps");
// Returns `["1.00", "MBps"]`