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

mcall

v0.1.1

Published

A lightweight function call management tool for debounce, throttle, and custom call control of function execution.

Downloads

3

Readme

mcall

A lightweight function call management tool for debounce, throttle, and custom call control of function execution.

中文说明

Installation

npm install mcall  

Basic Debounce (Default Mode)

import Mcall from 'mcall';  

// Create a default debounce task  
const task = new Mcall();  

// Multiple calls, only the last one will be executed  
task(() => {  
    console.log('Execute task 1');  
});  
task(() => {  
    console.log('Execute task 2');  
});  

Function Call Control Description

Executes the last passed function or concurrent.

| Type | Description |
|-----------|-------------------------------------|
| delay | Debounce by time, default 300ms delay |
| num | Debounce by count, default executes after 1000ms |
| batch | Concurrent debouncing with limited parallelism | | gap | Throttle, default executes every 200ms |
| wait | Custom, executes when .exec() is called |

Usage Examples

Custom Debounce Delay

// Create a debounce task with a 100ms delay  
const task = new Mcall({  
    delay: 100  
});  

Count-Based Control

// Create a count-controlled task, executes after accumulating 2 calls  
const task = Mcall({  
    num: 2  
});  

task(() => console.log('First call'));  
task(() => console.log('Second call'));  
task(() => console.log('Third call'));  

// Manually trigger execution  
task.exec();  

Concurrent limitation

// Create a parallel queue to maintain a fixed number of concurrent tasks.
const task = Mcall({
    batch: 2
});


task(() => new Promise(resolve=>setTimeout(() => resolve(console.log('Task 1')), 1000)));
task(() => new Promise(resolve=>setTimeout(() => resolve(console.log('Task 2')), 1000)));
task(() => new Promise(resolve=>setTimeout(() => resolve(console.log('Task 3')), 1000)));

Throttle Mode

// Create a throttle task with a 300ms interval  
const task = new Mcall({  
    gap: 300  
});  

// Frequent calls, but only executes once every 300ms  
task(() => {  
    console.log('Throttle execution 1');  
});  
task(() => {  
    console.log('Throttle execution 2');  
});  

Wait Mode

// Create a wait-mode task  
const task = new Mcall({  
    type: 'wait'  
});  

// Add multiple tasks, but they won't execute immediately  
task(() => console.log('Task 1'));  
task(() => console.log('Task 2'));  

// Manually trigger execution of the last task function  
task.exec();  

API

Instance Methods

import Mcall from 'mcall';  
const task = new Mcall(opt: McallOpt);  

Options Explanation

type McallOpt = {  
    type?: 'delay' | 'num' | 'gap' | 'wait' | 'batch';  
    delay?: number;  // Delay time (ms)  
    batch?: number;  // Number of concurrent tasks
    num?: number;    // Accumulated count  
    gap?: number;    // Throttle interval (ms)  
    onExec?: Function; // Execution event function callback  
    onRun?: Function; // Add execution event function callback  
    onEnd?: Function; // concurrent tasks end event function callback  
}  
  • task(fn: Function): Add an execution function (same as task.run())
  • task.run(fn: Function): Add an execution function
  • task.exec(): Manually trigger execution
  • task.clear(): Clear the task
  • task.close(): Destroy the instance
  • task.on(eventName: string, callback: Function): Event listener (eventName: 'run' | 'exec')

Notes

  • Default mode is debounce (300ms delay)
  • In throttle mode ('gap'), the first call executes immediately
  • In 'wait' mode, manual exec() is required to trigger execution
  • In count-based ('num') debounce mode, it executes by default after 1000ms. Set delay to 0 or Infinity to disable auto-execution, requiring manual exec()
  • Use close() to destroy the instance, cancel events, and timers

License

MIT