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

number-core

v0.0.6

Published

number的工具箱:round、toFixed纠正;负数千分符,数字转中文

Downloads

17

Readme

Install-下载


npm install number-core --save

usage-使用说明

虽然模仿react但不建议直接numberCore使用, 使用{ toFixedz }最大程度支持tree-shake

import NumberCore,{ toFixedz } from 'number-core'

API

引用方式: import numberCore,{ toFixedz } from 'number-core'

|Api |使用 | 举例| |:---: |:---: |:---:| |toFixedz | -10.215.toFixedz(2) 或 toFixedz(-10.215,2) | toFixedz(-10.215,2) =>'-10.22'| |roundz | roundz(value内容) | roundz(-11.5) => -12 | |qianfenfu | 千分符 qianfenfu(num,cent位数,isThousand是否千分符)|qianfenfu('-100000000.21',2)=> '-100,000,000.21' | |chinessNumber| chinessNumber(1000) | chinessNumber(1000)=>'壹仟元整'|

详解

1、toFixedz使用:

import numberCore,{ toFixedz } from 'number-core'

// 直接替换掉原来的 -----不推荐这样做
Number.prototype.toFixedz = numberCore.toFixedz

// 局部使用,传递两个参数
toFixedz(被取数(value),取多少位(de))

toFixedz: 解决-10.215 => toFixed(2) 的问题

2、roundz使用:

import numberCore,{ roundz } from 'number-core'
// 直接替换掉原来的 
Math.round = roundz
// 局部使用,传递两个参数
roundz(value)

Math.round带来的问题: -11.5 => -11

3、qianfenfu使用:

import NumberCore,{ qianfenfu } from 'number-core'
// 直接使用
let result = qianfenfu(1000)
// 或者
let result = numberCore.qianfenfu(1000)

4、chinessNumber使用:

import NumberCore,{ chinessNumber } from 'number-core'
// 直接使用
let result = chinessNumber(1000)   
// 或者
let result = numberCore.chinessNumber(1000)

版本记录

v0.0.6 2023-10-11

  • 提升单元测试的兼容

v0.0.5 2023-05-05

  • 优化toFixedz的方法

v0.0.3 2023-03-22

  • 修复toFixedz的处理方式

v0.0.2 2022-12-27

  • 插件发布