
Research
/Security News
Miasma Mini Shai-Hulud Hits ImmobiliareLabs npm Packages
Miasma Mini Shai-Hulud hits @immobiliarelabs Backstage plugins, targeting GitLab and LDAP auth packages on npm.
callbackbundler
Advanced tools
A JavaScript tool to bundle callbacks and attach to any object that supports event listener.
A tool to bundle callbacks and attach to any object that supports event listener.
It's recommended to install it as dependency.
npm install --save callbackbundler
Download the callbackbundler.min.js file and include it in your HTML.
<script src="path/to/src/callbackbundler.min.js"></script>
var CallbackBundler = require('callbackbundler');
var bundle = new CallbackBundler();
<!--<script src="path/to/src/callbackbundler.min.js"></script>-->
<script>
var bundle = new CallbackBundler();
</script>
CallbackBundler is extended from Array.prototype. Therefore, apart from the methods listed below, it can use every Array instance's methods that environment supports.
The examples below will use the functions and variables defined below:
var bundle = new CallbackBundler();
function callback1(){
console.log(1);
}
function callback2(){
console.log(this);
}
function callback(e, v){
console.log(e, v);
}
bundle.add(callback1);
bundle.add(callback2);
bundle.add(callback3);
/* OR */
bundle.add(callback1, callback2, callback3);
bundle.remove(callback1);
bundle.remove(callback2);
bundle.remove(callback3);
/* OR */
bundle.remove(callback1, callback2, callback3);
var elem = document.body, // or any object with event listener API
api = 'addEventListener', // or other equivalent methods, i.e., "on"
type = 'click'; // or other event types, i.e., "keypress"
bundle.attach(elem, api, type);
/**
* When document.body is clicked, console will print:
* (Using the functions declared above)
* => 1
* => <body>...</body>
* => MouseEvent {...}, undefined
*/
bundle.run('thisVal', [ // Pass arguments to each callback by array
undefined, // These arguments must be wrapped in another array
undefined, // If not an array, item will be auto-wrapped in a new array
['argument 0', true] // Using an array, you can pass as many arguments as you want
]);
/**
* Console will print:
* => 1
* => 'thisVal'
* => 'argument 0', true
*/
console.log(bundle.size);
// => 3
It will be useful if:
FAQs
A JavaScript tool to bundle callbacks and attach to any object that supports event listener.
The npm package callbackbundler receives a total of 3 weekly downloads. As such, callbackbundler popularity was classified as not popular.
We found that callbackbundler demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Research
/Security News
Miasma Mini Shai-Hulud hits @immobiliarelabs Backstage plugins, targeting GitLab and LDAP auth packages on npm.

Security News
Rolldown paused Rust React Compiler integration after a 5MB binary size increase raised concerns about shipping React-specific code to all Vite users.

Security News
/Research
Mini Shai-Hulud expands into the Go ecosystem after hitting LeoPlatform npm packages and targeting GitHub Actions workflows.