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

@tarsiidae/fn

v1.0.5

Published

A TypeScript Function Library

Downloads

144

Readme

@tarsiidae/fn

业务中常用的函数库

安装

yarn add @tarsiidae/fn
npm install @tarsiidae/fn
pnpm add @tarsiidae/fn

使用

formatThousand - 千分位格式化

将数字格式化为带千分位分隔符的字符串,支持截断小数位。

import { formatThousand } from '@tarsiidae/fn';

// 基本使用
console.log(formatThousand(1234567.89)); // "1,234,567.89"
console.log(formatThousand(1000.123)); // "1,000.12"
console.log(formatThousand('1234567.89')); // "1,234,567.89"

// 自定义小数位数
console.log(formatThousand(1234567.89, { decimal: 3 })); // "1,234,567.890"
console.log(formatThousand(1234567.89, { decimal: 1 })); // "1,234,567.8"
console.log(formatThousand(1234567.89, { decimal: 0 })); // "1,234,567"

// 不显示千分位分隔符
console.log(formatThousand(1234567.89, { showSeparator: false })); // "1234567.89"
console.log(formatThousand(1000.123, { showSeparator: false })); // "1000.12"

// 组合使用
console.log(formatThousand(1234567.89, { 
  decimal: 3, 
  showSeparator: false 
})); // "1234567.890"

参数说明

formatThousand(value, options?)

  • value number | string | undefined - 要格式化的数值
  • options object (可选) - 配置选项
    • decimal number (可选) - 保留的小数位数,默认为 2
    • showSeparator boolean (可选) - 是否显示千分位分隔符,默认为 true

特性

  • 截断小数 - 使用截断而非四舍五入,避免精度问题
  • 千分位分隔符 - 自动添加千分位分隔符,提高可读性
  • 灵活配置 - 支持自定义小数位数和分隔符显示
  • 类型安全 - 完整的 TypeScript 类型支持
  • 字符串支持 - 支持数字字符串输入

注意事项

  • 小数位采用截断方式,例如 1000.125 保留两位小数结果为 1000.12
  • decimal 为 0 时,会截断所有小数部分
  • 支持 undefined 和无效字符串输入,会返回 0.00

许可证

MIT