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

test-mode

v1.0.5

Published

仅用于测试

Readme

项目名称

简介

工具函数

函数说明

toDateString

将时间转换为指定格式的字符串。

参数:

  • time:时间,可以是字符串或日期对象。
  • format:可选,指定输出格式,默认为 "yyyy-MM-dd HH:mm:ss"

返回值:

  • 返回格式化后的日期字符串。

timeAgo

返回某个时间距离当前时间的描述。

参数:

  • time:需要语义化的时间,可以是字符串、数字或日期对象。
  • onlyDate:可选,超过30天是否仅返回日期。

返回值:

  • 返回描述时间的字符串,例如 "3天前"。

digit

数字前置补零。

参数:

  • num:需要补零的数字。
  • length:补零后的位数,默认为2。

返回值:

  • 返回补零后的字符串。

isCookieExist

检查指定名称的 cookie 是否存在。

参数:

  • name:cookie 名称。

返回值:

  • 如果存在返回 true,否则返回 false

isExternal

判断给定路径是否为外部链接。

参数:

  • path:需要判断的路径。

返回值:

  • 如果是外部链接返回 true,否则返回 false

filterNullValueObject

过滤对象中的空属性。

参数:

  • obj:需要过滤的对象。

返回值:

  • 返回过滤后的新对象。

getDisplayValue

表格列无数据显示 '-'

参数:

  • _row:表格行。
  • _column:表格列。
  • _cellValue:表格列内容值。
  • _index:行索引。

返回值:

  • 返回表格列内容值或 '-'

showKeyWord

处理关键词标红。

参数:

  • sourceStr:文本。
  • keywordArr:关键词数组。

返回值:

  • 返回标红后的 HTML 字符串。

timeToDate

将时间转换为时分秒格式。

参数:

  • time:时间,可以是数字或字符串。

返回值:

  • 返回格式化后的时间字符串。

timestampDate

将时间戳转换为日期字符串。

参数:

  • time:时间戳。

返回值:

  • 返回格式化后的日期字符串。

isValidJson

判断字符串是否为有效的 JSON 格式。

参数:

  • str:待判断的字符串。

返回值:

  • 如果是有效的 JSON 返回 true,否则返回 false

formatAmount

格式化金额为保留两位小数的 ¥xxxx.xx 格式。

参数:

  • amount:金额。

返回值:

  • 返回格式化后的金额字符串。

formatVersion

将版本号整数格式化为一位小数。

参数:

  • version:版本号。

返回值:

  • 返回格式化后的版本号字符串。

uuid

生成随机 ID。

参数:

  • length:可选,生成 ID 的长度,默认为 32。

返回值:

  • 返回生成的随机 ID 字符串。

deepClone

深度克隆对象。

参数:

  • obj:需要克隆的对象。

返回值:

  • 返回克隆后的对象。

formatFileSize

格式化文件大小。

参数:

  • bytes:文件大小(字节)。
  • length:可选,保留的小数位数。

返回值:

  • 返回格式化后的文件大小字符串。