New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

stact-hooks

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

stact-hooks - npm Package Compare versions

Comparing version 0.0.1 to 0.0.2

2

package.json
{
"name": "stact-hooks",
"version": "0.0.1",
"version": "0.0.2",
"description": "Manage a registry of function stacks and run them.",

@@ -5,0 +5,0 @@ "main": "stact-hooks.js",

@@ -8,4 +8,80 @@ stact-hooks

![Hook](http://www.thatfilmguy.net/wp-content/uploads/2011/12/Hook.jpg)
About
-----
`stact-hooks` is a simple wrapper around [stact](https://github.com/cpsubrian/node-stact).
It provides a registry-like interface to namespaced 'stacks' of functions.
Example
-------
```js
var hooks = require('stact-hooks')();
hooks('before:save').add(function (next) {
// Do something.
next();
});
hooks('before:save').add(function (next) {
// Do something.
next();
});
hooks('after:save').add(function (next) {
// Do something.
next();
});
hooks('before:save').run(function (err, results) {
if (err) // Handle err.
save(function (err) {
if (err) // Handle err.
hooks('after:save').run(function (err, results) {
if (err) // Handle err.
});
});
}
});
```
API
---
`stact-hooks` exports a single function, which returns a hook 'registry'.
The registry is a function that accepts one argument. You pass this function a string and
it returns you a *stact* function stack. Subsequent calls with the same
string will return the same stack.
```js
var createHooks = require('stact-hooks');
var hooks = createHooks();
hooks('validate').add(function (next) {
// Do something.
});
hooks('validate').add(function (next) {
// Do something.
});
// The 'validate' namespace is now a stack with two functions on it.
// You could 'run' this stack like so:
hooks('validate').run(function (err, results) {
});
// Or run it in series mode.
hooks('validate').runSeries(function (err, results) {
});
```
For more information please see [stact](https://github.com/cpsubrian/node-stact)
and [stac](https://github.com/cpsubrian/node-stac).
- - -

@@ -12,0 +88,0 @@

@@ -1,2 +0,2 @@

var Stact = require('stact');
var createStact = require('stact');

@@ -8,3 +8,3 @@ function createHooks (options) {

if (!stacks[name]) {
stacks[name] = new Stact(options);
stacks[name] = createStact(options);
}

@@ -11,0 +11,0 @@ return stacks[name];

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