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

@nightboy/js-utils-lite

v1.0.1

Published

A lightweight JavaScript utility library for common frontend and Node.js tasks.

Readme

@nightboy/js-utils-lite

一个零依赖 JavaScript 常用方法工具包,适合在浏览器、Node.js、现代打包工具中使用。

安装

npm install @nightboy/js-utils-lite

使用

import { deepClone, debounce, formatDate, uniqueBy } from '@nightboy/js-utils-lite';

const list = uniqueBy([{ id: 1 }, { id: 1 }, { id: 2 }], 'id');
const cloned = deepClone({ user: { name: 'codex' } });
const today = formatDate(new Date(), 'YYYY-MM-DD');
const onSearch = debounce((keyword) => {
  console.log(keyword);
}, 300);

CommonJS 也可以使用:

const { deepClone, throttle } = require('@nightboy/js-utils-lite');

方法列表

| 方法 | 说明 | | --- | --- | | isPlainObject(value) | 判断是否为普通对象 | | isEmpty(value) | 判断字符串、数组、Map、Set、对象是否为空 | | deepClone(value) | 深拷贝对象、数组、Date、RegExp、Map、Set,支持循环引用 | | debounce(callback, delay) | 创建防抖函数 | | throttle(callback, delay) | 创建节流函数 | | sleep(ms) | 等待指定毫秒数 | | clamp(value, min, max) | 将数字限制在范围内 | | chunk(list, size) | 按固定长度拆分数组 | | flatten(list, depth) | 按深度扁平化数组 | | uniqueBy(list, iteratee) | 数组去重,支持字段名或取值函数 | | groupBy(list, iteratee) | 数组分组,支持字段名或取值函数 | | range(start, end, step) | 生成数字区间数组 | | sumBy(list, iteratee) | 按字段名或取值函数统计数组总和 | | sortBy(list, iteratee, order) | 按字段名或取值函数排序数组 | | getValue(source, path, defaultValue) | 安全读取对象深层路径 | | setValue(source, path, value) | 按路径设置对象深层值 | | pick(source, keys) | 挑选对象字段 | | omit(source, keys) | 排除对象字段 | | merge(target, ...sources) | 深度合并普通对象 | | safeJsonParse(value, defaultValue) | 安全解析 JSON | | randomString(length) | 生成随机字符串 | | capitalize(value) | 首字母大写 | | camelCase(value) | 转换为 camelCase | | kebabCase(value) | 转换为 kebab-case | | escapeHtml(value) | 转义 HTML 特殊字符 | | unescapeHtml(value) | 还原常见 HTML 实体 | | formatDate(value, template) | 格式化日期 | | stringifyQuery(params) | 对象转查询字符串 | | parseQuery(query) | 查询字符串转对象 |

发布前检查

npm test
npm run pack:check

确认包名未被占用并登录 npm 后发布:

npm login
npm publish

如果要改包名,请先修改 package.json 中的 name 字段,再执行发布。