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

rene-utils

v1.0.0

Published

一个现代化的 TypeScript 工具函数库

Readme

r-utils

一个现代化的 TypeScript 工具函数库,提供了常用的字符串、数组、对象和日期处理函数。

安装

npm install r-utils

功能特性

  • 完整的 TypeScript 类型支持
  • 支持 ESM 和 CommonJS 模块规范
  • 包含字符串、数组、对象和日期处理等常用工具函数
  • 代码轻量化,可按需引入

使用示例

import { capitalize, unique, deepClone, formatDate } from 'r-utils';

// 字符串处理
console.log(capitalize('hello')); // 'Hello'

// 数组操作
console.log(unique([1, 1, 2, 3])); // [1, 2, 3]

// 对象处理
const obj = { a: 1, b: { c: 2 } };
const cloned = deepClone(obj);

// 日期格式化
console.log(formatDate(new Date(), 'YYYY-MM-DD')); // '2024-03-20'

API 文档

字符串工具

  • capitalize(str: string): string - 首字母大写
  • camelToKebab(str: string): string - 驼峰命名转连字符命名
  • kebabToCamel(str: string): string - 连字符命名转驼峰命名
  • truncate(str: string, length: number): string - 截取字符串并添加省略号

数组工具

  • unique<T>(arr: T[]): T[] - 数组去重
  • groupBy<T>(arr: T[], key: keyof T): Record<string, T[]> - 数组分组
  • flatten<T>(arr: (T | T[])[]): T[] - 数组扁平化
  • random<T>(arr: T[]): T - 获取数组中的随机元素

对象工具

  • deepClone<T>(obj: T): T - 深拷贝对象
  • get(obj: any, path: string | string[], defaultValue?: any): any - 获取对象指定路径的值
  • merge<T extends object>(target: T, ...sources: Partial<T>[]): T - 合并对象
  • removeEmpty<T extends object>(obj: T): Partial<T> - 移除对象中值为 null 或 undefined 的属性

日期工具

  • formatDate(date: Date | number, format?: string): string - 格式化日期
  • getRelativeTime(date: Date | number): string - 获取相对时间描述
  • addDays(date: Date, days: number): Date - 添加天数
  • isSameDay(date1: Date, date2: Date): boolean - 判断是否为同一天

开源协议

MIT