Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

callback-registry

Package Overview
Dependencies
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

callback-registry - npm Package Compare versions

Comparing version 2.2.5 to 2.2.6

81

lib/index.js

@@ -1,51 +0,48 @@

module.exports = function () {
"use strict";
var callbacks = {};
function add(key, callback) {
var callbacksForKey = callbacks[key];
if (!callbacksForKey) {
callbacksForKey = [];
callbacks[key] = callbacksForKey;
}
callbacksForKey.push(callback);
// remove function
return function(){
// get a new view of the collection(
"use strict";
function createRegistry() {
var callbacks = {};
function add(key, callback) {
var callbacksForKey = callbacks[key];
if (!callbacksForKey) {
callbacksForKey = [];
callbacks[key] = callbacksForKey;
}
callbacksForKey.push(callback);
return function () {
var allForKey = callbacks[key];
allForKey = allForKey.filter(function(item){
allForKey = allForKey.filter(function (item) {
return item !== callback;
});
callbacks[key] = allForKey;
};
}
function execute(key) {
var callbacksForKey = callbacks[key];
if (!callbacksForKey || callbacksForKey.length === 0){
return [];
}
var args = [].splice.call(arguments, 1);
var results = [];
callbacksForKey.forEach(function (callback) {
};
}
function execute(key) {
var argumentsArr = [];
for (var _i = 1; _i < arguments.length; _i++) {
argumentsArr[_i - 1] = arguments[_i];
}
var callbacksForKey = callbacks[key];
if (!callbacksForKey || callbacksForKey.length === 0) {
return [];
}
var results = [];
callbacksForKey.forEach(function (callback) {
try {
var result = callback.apply(undefined, args);
var result = callback.apply(undefined, argumentsArr);
results.push(result);
} catch (err) {
}
catch (err) {
results.push(undefined);
}
});
return results;
}
return {
add: add,
execute: execute
};
};
return results;
}
return {
add: add,
execute: execute
};
}
;
createRegistry.default = createRegistry;
module.exports = createRegistry;
//# sourceMappingURL=index.js.map
{
"name": "callback-registry",
"version": "2.2.5",
"description": "Registry for callbacks",
"main": "./lib/index.js",
"scripts": {
"test": "mocha tests/index.js",
"prepublish" : "npm run test"
},
"repository": {
"type": "git",
"url": "git+https://github.com/kirilpopov/callback-registry.git"
},
"keywords": [
"callbacks",
"registry",
"store",
"dispatcher"
],
"author": "Kiril Popov",
"license": "ISC",
"bugs": {
"url": "https://github.com/kirilpopov/callback-registry/issues"
},
"homepage": "https://github.com/kirilpopov/callback-registry#readme",
"devDependencies": {
"chai": "^3.5.0",
"mocha": "^2.5.3"
},
"publishConfig":{
"registry":"https://registry.npmjs.org"
}
"name": "callback-registry",
"version": "2.2.6",
"description": "Registry for callbacks",
"main": "./lib/index.js",
"scripts": {
"build": "tsc",
"test": "npm run build && mocha tests/index.js",
"prepublish": "npm run test"
},
"repository": {
"type": "git",
"url": "git+https://github.com/kirilpopov/callback-registry.git"
},
"keywords": [
"callbacks",
"registry",
"store",
"dispatcher"
],
"author": "Kiril Popov",
"license": "ISC",
"bugs": {
"url": "https://github.com/kirilpopov/callback-registry/issues"
},
"homepage": "https://github.com/kirilpopov/callback-registry#readme",
"devDependencies": {
"chai": "^3.5.0",
"mocha": "^2.5.3",
"typescript": "^2.3.4"
},
"publishConfig": {
"registry": "https://registry.npmjs.org"
}
}
# Intro
A simple registry for callbacks that allows you to add one or more callbacks
under some key and then execute all by just using the key.
under some key and then execute all callbacks under some key.
Example:
```javascript
const registryFactory = require('callback-registry');

@@ -10,0 +10,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc