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 🙏

© 2026 – Pkg Stats / Ryan Hefner

simplecount

v1.0.5

Published

a small tool for js count

Readme

simpleCount

解决 javascript 计算中因 IEEE 754 标准引起的,浮点数精度以及计算不准确的问题
且兼容超大数计算

如何使用

import {add,sub,mul,divi,simpleToFixed} from 'simplecount';

const a = 0.1
const b = 0.2
const c = 1.335
const addResult = add(a,b) //->'0.3'
const subResult = sub(a,b) //->'-0.1'
const mulResult = mul(a,b) //->'0.02'
const diviResult = divi(a,b) //->'0.50'
const simpleToFixedResult = simpleToFiexed(c) //->'1.34'

const d = Number.MAX_SAFE_INTEGER //->9007199254740991
const e = 11
const f = 3
const bigAddResult = add(d,e) //->'9007199254741002'
const bigSubResult = sub(bigAddResult,f) //->'9007199254740999'
const bigMulResult = mul(bigAddResult,f) //->'27021597764223006'
const bigDiviResult = divi(bigAddResult,f) //->'3002399751580334.00'
const bigstfResult = simpleToFiexed(bigAddResult) //->'9007199254741002.00'

安装

1.建议使用 npm 包安装

yarn add simplecount
或者
npm install simplecount

2.浏览器环境可直接添加编译完成后的文件引用

<script type="text/javascript" src="simplecount.js"></script>

API 列表

add(a,b) 返回结果字符串,加法,a+b
sub(a,b) 返回结果字符串,减法,a-b
mul(a,b) 返回结果字符串,乘法,a*b
divi(a,b,c) 返回结果字符串,除法,a/b,保留 c 位小数,c 可不传,默认为 2
simpleToFixed(a,c) 返回结果字符串,四舍五入重构toFixed,对 a 进行定点表示法格式化,c 表示小数点后数字的个数,c可不传,默认为 2

module 环境使用:

import {add,sub,mul,divi,simpleToFixed} from 'simplecount';

commonjs 环境使用:

const {add,sub,mul,divi,simpleToFixed} = require('simplecount');

浏览器环境使用:

var add = window.simplecount.add;
var sub = window.simplecount.sub;
var mul = window.simplecount.mul;
var divi = window.simplecount.divi;
var simpleToFixed = window.simplecount.simpleToFixed;

单元测试

运行:
yarn test
yarn test:add
yarn test:sub
yarn test:mul
yarn test:divi

simpleCount

a small and simple tools for js count accuracy problems