hookable 5.5.0 → 5.5.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 CHANGED
@@ -2,11 +2,11 @@
2
2
 
3
3
  [![npm version][npm-version-src]][npm-version-href]
4
4
  [![npm downloads][npm-downloads-src]][npm-downloads-href]
5
- [![packagephobia][packagephobia-src]][packagephobia-href]
6
- [![Github Actions CI][github-actions-ci-src]][github-actions-ci-href]
5
+ [![bundle][bundle-src]][bundle-href]
7
6
  [![Codecov][codecov-src]][codecov-href]
7
+ [![License][license-src]][license-href]
8
8
 
9
- > Awaitable hook system
9
+ Awaitable hooks system.
10
10
 
11
11
  ## Install
12
12
 
@@ -255,17 +255,13 @@ Thanks to [Joe Paice](https://github.com/RGBboy) for donating [hookable](https:/
255
255
  MIT - Made with 💖
256
256
 
257
257
  <!-- Badges -->
258
- [npm-version-src]: https://flat.badgen.net/npm/dt/hookable
258
+ [npm-version-src]: https://img.shields.io/npm/v/hookable?style=flat&colorA=18181B&colorB=F0DB4F
259
259
  [npm-version-href]: https://npmjs.com/package/hookable
260
-
261
- [npm-downloads-src]: https://flat.badgen.net/npm/v/hookable
260
+ [npm-downloads-src]: https://img.shields.io/npm/dm/hookable?style=flat&colorA=18181B&colorB=F0DB4F
262
261
  [npm-downloads-href]: https://npmjs.com/package/hookable
263
-
264
- [github-actions-ci-src]: https://flat.badgen.net/github/checks/unjs/hookable/main
265
- [github-actions-ci-href]: https://github.com/unjs/hookable/actions
266
-
267
- [codecov-src]: https://flat.badgen.net/codecov/c/github/unjs/hookable
268
- [codecov-href]: https://codecov.io/gh/unjs/hookable
269
-
270
- [packagephobia-src]: https://flat.badgen.net/packagephobia/install/hookable
271
- [packagephobia-href]: https://packagephobia.now.sh/result?p=hookable
262
+ [codecov-src]: https://img.shields.io/codecov/c/gh/unjs/hookable/main?style=flat&colorA=18181B&colorB=F0DB4F
263
+ [codecov-href]: https://codecov.io/gh/unjs/h3
264
+ [bundle-src]: https://img.shields.io/bundlephobia/minzip/hookable?style=flat&colorA=18181B&colorB=F0DB4F
265
+ [bundle-href]: https://bundlephobia.com/result?p=hookable
266
+ [license-src]: https://img.shields.io/github/license/unjs/hookable.svg?style=flat&colorA=18181B&colorB=F0DB4F
267
+ [license-href]: https://github.com/unjs/hookable/blob/main/LICENSE
package/dist/index.cjs CHANGED
@@ -43,14 +43,16 @@ function serial(tasks, function_) {
43
43
  const defaultTask = { run: (function_) => function_() };
44
44
  const _createTask = () => defaultTask;
45
45
  const createTask = typeof console.createTask !== "undefined" ? console.createTask : _createTask;
46
- function serialTaskCaller(hooks, name, ...args) {
46
+ function serialTaskCaller(hooks, args) {
47
+ const name = args.shift();
47
48
  const task = createTask(name);
48
49
  return hooks.reduce(
49
50
  (promise, hookFunction) => promise.then(() => task.run(() => hookFunction(...args))),
50
51
  Promise.resolve()
51
52
  );
52
53
  }
53
- function parallelTaskCaller(hooks, name, ...args) {
54
+ function parallelTaskCaller(hooks, args) {
55
+ const name = args.shift();
54
56
  const task = createTask(name);
55
57
  return Promise.all(hooks.map((hook) => task.run(() => hook(...args))));
56
58
  }
@@ -183,9 +185,11 @@ class Hookable {
183
185
  }
184
186
  }
185
187
  callHook(name, ...arguments_) {
188
+ arguments_.unshift(name);
186
189
  return this.callHookWith(serialTaskCaller, name, ...arguments_);
187
190
  }
188
191
  callHookParallel(name, ...arguments_) {
192
+ arguments_.unshift(name);
189
193
  return this.callHookWith(parallelTaskCaller, name, ...arguments_);
190
194
  }
191
195
  callHookWith(caller, name, ...arguments_) {
package/dist/index.mjs CHANGED
@@ -41,14 +41,16 @@ function serial(tasks, function_) {
41
41
  const defaultTask = { run: (function_) => function_() };
42
42
  const _createTask = () => defaultTask;
43
43
  const createTask = typeof console.createTask !== "undefined" ? console.createTask : _createTask;
44
- function serialTaskCaller(hooks, name, ...args) {
44
+ function serialTaskCaller(hooks, args) {
45
+ const name = args.shift();
45
46
  const task = createTask(name);
46
47
  return hooks.reduce(
47
48
  (promise, hookFunction) => promise.then(() => task.run(() => hookFunction(...args))),
48
49
  Promise.resolve()
49
50
  );
50
51
  }
51
- function parallelTaskCaller(hooks, name, ...args) {
52
+ function parallelTaskCaller(hooks, args) {
53
+ const name = args.shift();
52
54
  const task = createTask(name);
53
55
  return Promise.all(hooks.map((hook) => task.run(() => hook(...args))));
54
56
  }
@@ -181,9 +183,11 @@ class Hookable {
181
183
  }
182
184
  }
183
185
  callHook(name, ...arguments_) {
186
+ arguments_.unshift(name);
184
187
  return this.callHookWith(serialTaskCaller, name, ...arguments_);
185
188
  }
186
189
  callHookParallel(name, ...arguments_) {
190
+ arguments_.unshift(name);
187
191
  return this.callHookWith(parallelTaskCaller, name, ...arguments_);
188
192
  }
189
193
  callHookWith(caller, name, ...arguments_) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hookable",
3
- "version": "5.5.0",
3
+ "version": "5.5.1",
4
4
  "description": "Awaitable hook system",
5
5
  "keywords": [
6
6
  "hook",