@pxxtech/unit-conversion
TypeScript icon, indicating that this package has built-in type declarations

3.0.0 • Public • Published

@scumon/unit-conversion

NPM version NPM downloads

一些简单的单位转换,比如:长度、质量、时间等。

下载

yarn add @scumon/unit-conversion -S

使用

import { g_kg } from "@scumon/unit-conversion";

g_kg(1000); // => 1

全局配置

import { config } from "@scumon/unit-conversion";

// 计算发生错误希望返回什么
config.error = "--";

// 所有结果统一配置,具体参考BigNumber文档
config.formatResult = (BigNumber) => {
  return BigNumber.toFixed(2);
};

拓展

import { expand, processing } from "@scumon/unit-conversion";

expand.x_y = (value: any, config: any) => {
  return processing(
    value,
    (BigNumber: any) => BigNumber.multipliedBy(1000000),
    config
  );
};

Package Sidebar

Install

npm i @pxxtech/unit-conversion

Weekly Downloads

11

Version

3.0.0

License

MIT

Unpacked Size

19.5 kB

Total Files

71

Last publish

Collaborators

  • imwangming