Registry / http-networking / metal-debounce

metal-debounce

JSON →
library2.0.2jsnpmunverified

metal-debounce is a utility library providing a debounce function, originally part of the deprecated Metal.js framework. It delays the execution of a function until a specified time has elapsed since its last invocation, a common pattern for optimizing event handlers (e.g., input, resize, scroll) by preventing excessive calls. The current stable version is 2.0.2, last published approximately seven years ago. As the Metal.js framework itself is no longer actively maintained for open-source releases, this package should be considered abandoned. It likely targets older JavaScript environments and CommonJS modules, lacking modern features like native ESM support or TypeScript definitions. Alternatives like `lodash.debounce` or `debounce-fn` offer more robust and actively maintained solutions.

npm install metal-debounce
INSTALL
IMPORT
SIG · METAL-DEBOUNCE
M
metal-debounce
http-networkingjavascriptv2.0.2
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

debounce
const debounce = require('metal-debounce');
import debounce from 'metal-debounce';
This package is CJS-only. ESM imports are not supported.
debounce function
const debounce = require('metal-debounce'); const debouncedFunction = debounce(() => console.log('Action!'), 200);
The `require` call directly provides the debounce function.

Demonstrates basic usage of the `debounce` function to limit repeated calls, such as from rapid user input.

const debounce = require('metal-debounce'); function logActivity(message) { console.log(`Activity: ${message} at ${new Date().toLocaleTimeString()}`); } // Create a debounced version of logActivity that waits 500ms const debouncedLog = debounce(logActivity, 500); console.log('Simulating rapid events...'); debouncedLog('Event 1'); debouncedLog('Event 2'); debouncedLog('Event 3'); setTimeout(() => { console.log('Waiting 600ms after last debounced call...'); debouncedLog('Event 4 (should trigger)'); }, 600); setTimeout(() => { console.log('Simulating more rapid events after initial trigger...'); debouncedLog('Event 5'); debouncedLog('Event 6'); }, 1200); setTimeout(() => { console.log('Final wait...'); }, 2000);
Debug
Known issues
breakingThe `metal-debounce` package, along with its parent Metal.js framework, is officially deprecated and abandoned. No further active development, new features, or maintenance is expected.
fix
Migrate to a currently maintained debounce utility like `lodash.debounce`, `debounce-fn`, or a modern framework's built-in debounce. These offer better support, performance, and often ESM compatibility.
affects: >=2.0.0
gotchaThis package is designed for CommonJS environments and does not natively support ES Modules (`import`/`export` syntax). Attempting to use ESM imports will result in runtime errors.
fix
Always use `require('metal-debounce')` to import the utility. For modern projects requiring ESM, consider alternative, actively maintained debounce libraries.
affects: >=2.0.0
gotchaThe package's age (last updated 7 years ago) means it likely lacks TypeScript definitions, modern JavaScript syntax (ES6+), and might not be optimized for current Node.js or browser environments.
fix
While functional for basic debounce needs in older environments, developers should be aware of potential compatibility issues or the need for manual type declarations in TypeScript projects. Prefer modern alternatives for new development.
affects: >=2.0.0
Errors
Common errors & fixes
TypeError: debounce is not a function
Attempting to destructure a CommonJS module that exports a single function directly, or incorrect import syntax.
fix
Ensure you are using `const debounce = require('metal-debounce');` to correctly import the function, as it's a direct export.
SyntaxError: Cannot use import statement outside a module
Attempting to use ES module `import` syntax in a CommonJS-only environment (e.g., an older Node.js project or without proper transpilation/configuration).
fix
Change your import statement to `const debounce = require('metal-debounce');`. If your project requires ESM, you must migrate to a different, actively maintained debounce library that explicitly supports ESM.
Upgrade
Version history
2.0.2latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
2 hits · last 30 days
node
2
Resources
metal-debounce — npm install metal-debounce · libregistry