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

elegant-tools-js

v1.0.2

Published

A powerful TypeScript utility library with browser fingerprinting, debouncing, throttling, and more

Readme

elegant-tools-js

一个强大的 TypeScript 工具库,提供浏览器指纹识别、防抖、节流等常用工具函数。

特性

  • 浏览器指纹识别 - 基于多维度特征生成唯一标识
  • 防抖 & 节流 - 优化事件处理性能
  • 深拷贝 - 完整的对象克隆支持
  • 唯一ID生成 - 时间戳+随机数组合
  • 日期格式化 - 灵活的日期格式化
  • 数组操作 - 智能去重工具
  • URL工具 - 查询字符串解析与生成
  • 设备检测 - 移动设备识别
  • 随机工具 - 随机数与字符串生成

安装

npm install elegant-tools-js
# 或
yarn add elegant-tools-js

快速开始

ES6+ 模块

import { Utils } from 'elegant-tools-js';

// 防抖 - 避免频繁触发
const debouncedFunction = Utils.debounce(() => {
  console.log('防抖执行');
}, 1000);
window.addEventListener('resize', debouncedFunction);

// 节流 - 控制执行频率
const throttledFunction = Utils.throttle(() => {
  console.log('节流执行');
}, 1000);
window.addEventListener('scroll', throttledFunction);

// 浏览器指纹 - 获取唯一标识
const fingerprint = Utils.getBrowserFingerprint();
console.log('浏览器指纹:', fingerprint);

// 深拷贝对象
const original = { a: 1, b: { c: 2 } };
const copy = Utils.deepClone(original);

// 生成唯一ID
const id = Utils.generateId();

// 格式化日期
Utils.formatDate(new Date(), 'YYYY-MM-DD HH:mm:ss');

// 数组去重
Utils.uniqueArray([1, 2, 2, 3]); // [1, 2, 3]

// 检查移动设备
if (Utils.isMobile()) {
  console.log('移动设备');
}

// 随机数
Utils.random(1, 100); // 1-100 之间的随机整数

// 驼峰转短横线
Utils.camelToKebab('helloWorld'); // 'hello-world'

CommonJS

const { Utils } = require('elegant-tools-js');

// 使用方式与 ES6+ 模块相同

主要 API

浏览器指纹

Utils.getBrowserFingerprint(): string

获取基于浏览器特征的指纹信息,特征包括 User Agent、屏幕信息、时区、硬件信息等。

事件优化

// 防抖
Utils.debounce(func, wait)

// 节流
Utils.throttle(func, limit)

对象操作

// 深拷贝
Utils.deepClone(obj)

// 生成唯一ID
Utils.generateId()

日期处理

// 格式化日期
Utils.formatDate(date, format)

支持 YYYY, MM, DD, HH, mm, ss 占位符。

数组工具

// 数组去重
Utils.uniqueArray(arr)

// 根据键去重
Utils.uniqueArrayByKey(arr, key)

URL 工具

// 解析查询字符串
Utils.parseQuery(query)

// 生成查询字符串
Utils.stringifyQuery(params)

设备检测

Utils.isMobile(): boolean