npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

amountjs

v1.2.7

Published

**一个专注于处理数字与货币显示的小型ts库**

Downloads

43

Readme

amount.js

一个专注于处理数字与货币显示的小型ts库

特性

  • 小而快
  • 使用异常简单,由于Ts加持,api都有语法提示
  • 体积只有7.42KB,经过gzip压缩后,体积将进一步压缩至3.29KB

安装

npm i amountjs

导入

import amountjs from 'amountjs';

使用

库导出单个函数amountjs,必传项接收类型为number或string的值

千位分隔:

amountjs({amount: 1000, separate: true}) => 1,000

小数最大位数:

amountjs({amount: 100.978, maxDigits: 2}) => 100.97

小数最小位数:

amountjs({amount: 100, minDigits: 2}) => 100.00

显示正数前的加号:

amountjs({amount: 100, showPlusMark: true}) => +100

显示货币单位:

amountjs({amount: 100000000, unit: true}) => 1亿

货币单位目前最大支持显示到亿

小数最大位数类型(截断 | 四舍五入):

amountjs({amount: 123.678, maxDigits: 2, digitsType: 'float'}) => 123.68

以上特性可以相互组合,来得到您最终想要的效果!

预览

npm run start

构建

请使用webpack来构建本项目

npm run build:webpack

API

| 属性 | 类型 | 必传 | 默认值 | 描述 | |--------------|---------------|-----|-------|--------------------------------| | amount | string、number | 是 | - | 需要处理的值 | | separate | boolean | 否 | false | 千位分隔 | | showPlusMark | boolean | 否 | false | 显示正数前的加号 | | digitsType | string | 否 | split | 小数限制位数时的类型。split:截断;float:四舍五入 | | maxDigits | number | 否 | - | 小数位最大长度 | | minDigits | number | 否 | - | 小数位最小长度,不足补0 | | unit | boolean | 否 | false | 显示RMB货币单位 | | noWarn | boolean | 否 | false | 是否显示控制台的警告信息 |

反馈

如在使用过程中,遇到问题或发现bug,欢迎提交issue或者发邮件给