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

hook-up

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hook-up - npm Package Compare versions

Comparing version 0.2.1 to 0.2.2

23

lib/hook-up.js

@@ -28,19 +28,32 @@ (function() {

setupAction = function(actionName, obj, arg) {
var Promise, action, call, catcher, def, hookIn, names;
catcher = arg["catch"], names = arg.names, def = arg["default"], Promise = arg.Promise;
var Promise, action, args, call, catcher, def, hookIn, names;
catcher = arg["catch"], names = arg.names, def = arg["default"], Promise = arg.Promise, args = arg.args;
if ((catcher != null) && !isFunction(catcher)) {
catcher = catcher[actionName];
}
if (args != null) {
if (!isArray(args)) {
args = [obj, args];
} else {
args.unshift(obj);
}
} else {
args = [obj];
}
call = function(o) {
var promise;
var _args, promise;
if (o == null) {
o = obj;
}
_args = args.slice();
_args.unshift(o);
promise = (action._chain.reduce((function(lastPromise, hooks) {
if (hooks.length === 1) {
return lastPromise.then(hooks[0].bind(obj, o, obj));
return lastPromise.then(function() {
return hooks[0].apply(obj, _args);
});
} else {
return lastPromise.then(function() {
return Promise.all(hooks.map(function(hook) {
return hook.call(obj, o, obj);
return hook.apply(obj, _args);
}));

@@ -47,0 +60,0 @@ });

{
"name": "hook-up",
"description": "Create your own hook api with 2-dimensional hooks - better than events or simple hooks",
"version": "0.2.1",
"version": "0.2.2",
"homepage": "https://github.com/paulpflug/",

@@ -6,0 +6,0 @@ "author": {

@@ -72,3 +72,4 @@ # hook-up

"cache.get": (e) => { console.error(e) }
}
},
args: [someArg]
})

@@ -79,4 +80,5 @@

// (see below)
program.run.hookIn((state,{config}) => {
program.run.hookIn((state,{config},someArg) => {
// config equals program.config
// someArg is passed from above
// it is recommend to test the state if you depend on it

@@ -115,2 +117,3 @@ // as you have no idea what the previous cbs did

Promise | Object | native Promise | Promise lib to use
args | Object or Array of Objects | - | additonal args passed on each action call
names | Object | - | see below

@@ -117,0 +120,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