@classytic/notifications 0.0.1 → 2.0.0

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.
@@ -1,45 +0,0 @@
1
- /**
2
- * Hook Merging Utility
3
- * @classytic/notifications
4
- *
5
- * Merges multiple hook configurations into single object
6
- */
7
-
8
- /**
9
- * Merge multiple hook configurations
10
- * Each event can have multiple handlers from different sources
11
- *
12
- * @param {...Object} hookConfigs - Hook configuration objects
13
- * @returns {Object} Merged hooks
14
- *
15
- * @example
16
- * const hooks = mergeHooks(
17
- * { 'user.created': [handler1] },
18
- * { 'user.created': [handler2], 'user.deleted': [handler3] }
19
- * );
20
- * // Result: { 'user.created': [handler1, handler2], 'user.deleted': [handler3] }
21
- */
22
- export function mergeHooks(...hookConfigs) {
23
- const merged = {};
24
-
25
- hookConfigs.forEach(config => {
26
- if (!config || typeof config !== 'object') {
27
- return;
28
- }
29
-
30
- Object.entries(config).forEach(([event, handlers]) => {
31
- if (!merged[event]) {
32
- merged[event] = [];
33
- }
34
-
35
- // Ensure handlers is an array
36
- const handlerArray = Array.isArray(handlers) ? handlers : [handlers];
37
- merged[event].push(...handlerArray);
38
- });
39
- });
40
-
41
- return merged;
42
- }
43
-
44
- export default mergeHooks;
45
-