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

hongfangze-function

v1.0.0

Published

comm.function

Readme

函数相关操作

介绍

目前包含了防抖、节流的封装

开始使用

npm install hongfangze-function

具体前端使用方式见包内demo文件

// import { throttle,debounce } from "hongfangze-function";
// import * as hfzfunction from "hongfangze-function";

/**
 * 函数防抖
 * - 简单的说,当一个动作连续触发,只执行最后一次。
 * - 打个比方,坐公交,司机需要等最后一个人进入才能关门。每次进入一个人,司机就会多等待几秒再关门。
 * - 函数防抖(debounce)的应用场景:\
 * 连续的事件,只需触发一次的回调场景有:\
 * 1、搜索框搜索输入。只需要用户最后一次输入完再发送请求 \
 * 2、手机号、邮箱格式的输入验证检测 \
 * 3、窗口大小的 resize 。只需窗口调整完成后,计算窗口的大小,防止重复渲染。 \
 * - 调用示例:\
 * const input1 = document.getElementById('input1'); \
 * input1.addEventListener('keyup', debounce(function () { \
 *      console.log(input1.value); \
 * }, 600)) \
 * @param {Function} fn 实际运行的函数
 * @param {number} [delay] 多少时间内的重复调用将被忽略,单位毫秒,默认300
 * @return {*}
 */
export declare const debounce: (fn: any, delay?: number) => any;
/**
 * 函数节流
 * - 限制一个函数在一定时间内只能执行一次
 * - 举个例子,乘坐地铁,过闸机时,每个人进入后3秒后门关闭,等待下一个人进入。
 * 函数节流(throttle)的应用场景:\
 * 间隔一段时间执行一次回调的场景有:\
 * 1、滚动加载,加载更多或滚动到底部监听 \
 * 2、谷歌搜索框,搜索联想功能 \
 * 3、高频点击提交,表单重复提交 \
 * 4、省市信息对应字母快速选择 \
 * - 调用示例:\
 * let div1 = document.getElementById('div1'); \
 * div1.addEventListener('drag', throttle(function(e) { \
 *     console.log(e.offsetX, e.offsetY); \
 *  }, 100));
 * @param {Function} func 实际运行的函数
 * @param {number} [wait] 多少时间内的重复调用将被忽略,单位毫秒,默认300
 * @param {boolean} [immediate] 是否立即执行(即忽略本次节流)
 * @return {*}  {*}
 */
export declare const throttle: (func: Function, wait?: number, immediate?: boolean) => any;

版本迭代记录

2025-04-07 v1.0.0

  • 实现函数防抖、函数节流。