hookable 6.0.0-rc.2 → 6.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +5 -6
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -163,10 +163,11 @@ Used by class itself to **sequentially** call handlers of a specific hook.
|
|
|
163
163
|
|
|
164
164
|
If you need custom control over how hooks are called, you can provide a custom function that will receive an array of handlers of a specific hook.
|
|
165
165
|
|
|
166
|
-
`callerFn` if a callback function that accepts
|
|
166
|
+
`callerFn` if a callback function that accepts 3 arguments, `hooks`, `args` and `name`:
|
|
167
167
|
|
|
168
168
|
- `hooks`: Array of user hooks to be called
|
|
169
169
|
- `args`: Array of arguments that should be passed each time calling a hook
|
|
170
|
+
- `name`: Name of the hook
|
|
170
171
|
|
|
171
172
|
### `deprecateHook (old, name)`
|
|
172
173
|
|
package/dist/index.d.mts
CHANGED
|
@@ -46,7 +46,7 @@ declare class Hookable<HooksT extends Record<string, any> = Record<string, HookC
|
|
|
46
46
|
removeAllHooks(): void;
|
|
47
47
|
callHook<NameT extends HookNameT>(name: NameT, ...args: Parameters<InferCallback<HooksT, NameT>>): Promise<any> | void;
|
|
48
48
|
callHookParallel<NameT extends HookNameT>(name: NameT, ...args: Parameters<InferCallback<HooksT, NameT>>): Promise<any[]> | void;
|
|
49
|
-
callHookWith<NameT extends HookNameT, CallFunction extends (hooks: HookCallback[], args: Parameters<InferCallback<HooksT, NameT
|
|
49
|
+
callHookWith<NameT extends HookNameT, CallFunction extends (hooks: HookCallback[], args: Parameters<InferCallback<HooksT, NameT>>, name: NameT) => any>(caller: CallFunction, name: NameT, args: Parameters<InferCallback<HooksT, NameT>>): ReturnType<CallFunction>;
|
|
50
50
|
beforeEach(function_: (event: InferSpyEvent<HooksT>) => void): () => void;
|
|
51
51
|
afterEach(function_: (event: InferSpyEvent<HooksT>) => void): () => void;
|
|
52
52
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -37,12 +37,12 @@ function callHooks(hooks, args, startIndex, task) {
|
|
|
37
37
|
return Promise.reject(error);
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
|
-
function serialTaskCaller(hooks, args) {
|
|
41
|
-
if (hooks.length > 0) return callHooks(hooks, args, 0, createTask(
|
|
40
|
+
function serialTaskCaller(hooks, args, name) {
|
|
41
|
+
if (hooks.length > 0) return callHooks(hooks, args, 0, createTask(name));
|
|
42
42
|
}
|
|
43
|
-
function parallelTaskCaller(hooks, args) {
|
|
43
|
+
function parallelTaskCaller(hooks, args, name) {
|
|
44
44
|
if (hooks.length > 0) {
|
|
45
|
-
const task = createTask(
|
|
45
|
+
const task = createTask(name);
|
|
46
46
|
return Promise.all(hooks.map((hook) => task.run(() => hook(...args))));
|
|
47
47
|
}
|
|
48
48
|
}
|
|
@@ -164,8 +164,7 @@ var Hookable = class {
|
|
|
164
164
|
context: {}
|
|
165
165
|
} : void 0;
|
|
166
166
|
if (this._before) callEachWith(this._before, event);
|
|
167
|
-
const
|
|
168
|
-
const result = caller(this._hooks[name] ? [...this._hooks[name]] : [], _args);
|
|
167
|
+
const result = caller(this._hooks[name] ? [...this._hooks[name]] : [], args, name);
|
|
169
168
|
if (result instanceof Promise) return result.finally(() => {
|
|
170
169
|
if (this._after && event) callEachWith(this._after, event);
|
|
171
170
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hookable",
|
|
3
|
-
"version": "6.0.
|
|
3
|
+
"version": "6.0.1",
|
|
4
4
|
"description": "Awaitable hook system",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"hook",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"lint": "eslint --cache . && prettier -c src test",
|
|
29
29
|
"lint:fix": "eslint --cache . --fix && prettier -c src test -w",
|
|
30
30
|
"prepublish": "pnpm build",
|
|
31
|
-
"release": "pnpm test && pnpm build && changelogen --release --
|
|
31
|
+
"release": "pnpm test && pnpm build && changelogen --release --publish --push",
|
|
32
32
|
"test": "pnpm lint && vitest run --coverage",
|
|
33
33
|
"test:types": "tsc --noEmit"
|
|
34
34
|
},
|