yummies 7.11.0 → 7.13.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.
Files changed (159) hide show
  1. package/README.md +5 -87
  2. package/async.cjs +179 -48
  3. package/async.cjs.map +1 -1
  4. package/async.d.ts +125 -7
  5. package/async.js +180 -54
  6. package/async.js.map +1 -1
  7. package/chunk-CVq3Gv4J.cjs +50 -0
  8. package/chunk-YKewjYmz.js +37 -0
  9. package/common.cjs +48 -8
  10. package/common.cjs.map +1 -1
  11. package/common.d.ts +53 -2
  12. package/common.js +49 -11
  13. package/common.js.map +1 -1
  14. package/complex.cjs +275 -128
  15. package/complex.cjs.map +1 -1
  16. package/complex.d.ts +66 -0
  17. package/complex.js +275 -133
  18. package/complex.js.map +1 -1
  19. package/cookie.cjs +17 -7
  20. package/cookie.cjs.map +1 -1
  21. package/cookie.d.ts +26 -0
  22. package/cookie.js +18 -9
  23. package/cookie.js.map +1 -1
  24. package/css.cjs +163 -39
  25. package/css.cjs.map +1 -1
  26. package/css.d.ts +115 -6
  27. package/css.js +159 -41
  28. package/css.js.map +1 -1
  29. package/data.cjs +90 -55
  30. package/data.cjs.map +1 -1
  31. package/data.d.ts +50 -0
  32. package/data.js +91 -61
  33. package/data.js.map +1 -1
  34. package/date-time.cjs +594 -412
  35. package/date-time.cjs.map +1 -1
  36. package/date-time.d.ts +105 -0
  37. package/date-time.js +591 -421
  38. package/date-time.js.map +1 -1
  39. package/device.cjs +65 -23
  40. package/device.cjs.map +1 -1
  41. package/device.d.ts +49 -0
  42. package/device.js +66 -31
  43. package/device.js.map +1 -1
  44. package/encodings.cjs +275 -266
  45. package/encodings.cjs.map +1 -1
  46. package/encodings.d.ts +25 -0
  47. package/encodings.js +276 -268
  48. package/encodings.js.map +1 -1
  49. package/errors.cjs +36 -18
  50. package/errors.cjs.map +1 -1
  51. package/errors.d.ts +17 -0
  52. package/errors.js +35 -19
  53. package/errors.js.map +1 -1
  54. package/file.cjs +58 -24
  55. package/file.cjs.map +1 -1
  56. package/file.d.ts +32 -0
  57. package/file.js +59 -27
  58. package/file.js.map +1 -1
  59. package/format.cjs +125 -83
  60. package/format.cjs.map +1 -1
  61. package/format.d.ts +18 -0
  62. package/format.js +118 -82
  63. package/format.js.map +1 -1
  64. package/html.cjs +242 -137
  65. package/html.cjs.map +1 -1
  66. package/html.d.ts +81 -0
  67. package/html.js +239 -150
  68. package/html.js.map +1 -1
  69. package/id.cjs +90 -17
  70. package/id.cjs.map +1 -1
  71. package/id.d.ts +16 -0
  72. package/id.js +89 -24
  73. package/id.js.map +1 -1
  74. package/imports.cjs +57 -29
  75. package/imports.cjs.map +1 -1
  76. package/imports.d.ts +24 -0
  77. package/imports.js +56 -31
  78. package/imports.js.map +1 -1
  79. package/math.cjs +32 -6
  80. package/math.cjs.map +1 -1
  81. package/math.d.ts +33 -0
  82. package/math.js +33 -10
  83. package/math.js.map +1 -1
  84. package/media.cjs +291 -84
  85. package/media.cjs.map +1 -1
  86. package/media.d.ts +204 -2
  87. package/media.js +290 -93
  88. package/media.js.map +1 -1
  89. package/mobx.cjs +449 -193
  90. package/mobx.cjs.map +1 -1
  91. package/mobx.d.ts +108 -0
  92. package/mobx.js +447 -200
  93. package/mobx.js.map +1 -1
  94. package/ms.cjs +37 -10
  95. package/ms.cjs.map +1 -1
  96. package/ms.d.ts +16 -0
  97. package/ms.js +38 -13
  98. package/ms.js.map +1 -1
  99. package/number.cjs +29 -7
  100. package/number.cjs.map +1 -1
  101. package/number.d.ts +16 -0
  102. package/number.js +30 -9
  103. package/number.js.map +1 -1
  104. package/package.json +11 -3
  105. package/parser.cjs +117 -64
  106. package/parser.cjs.map +1 -1
  107. package/parser.d.ts +17 -0
  108. package/parser.js +111 -64
  109. package/parser.js.map +1 -1
  110. package/price.cjs +24 -18
  111. package/price.cjs.map +1 -1
  112. package/price.d.ts +24 -0
  113. package/price.js +25 -20
  114. package/price.js.map +1 -1
  115. package/random.cjs +95 -13
  116. package/random.cjs.map +1 -1
  117. package/random.d.ts +80 -0
  118. package/random.js +96 -22
  119. package/random.js.map +1 -1
  120. package/react.cjs +673 -214
  121. package/react.cjs.map +1 -1
  122. package/react.d.ts +21 -0
  123. package/react.js +674 -239
  124. package/react.js.map +1 -1
  125. package/sound.cjs +30 -9
  126. package/sound.cjs.map +1 -1
  127. package/sound.d.ts +16 -0
  128. package/sound.js +31 -11
  129. package/sound.js.map +1 -1
  130. package/storage.cjs +49 -50
  131. package/storage.cjs.map +1 -1
  132. package/storage.d.ts +24 -0
  133. package/storage.js +50 -53
  134. package/storage.js.map +1 -1
  135. package/text.cjs +67 -34
  136. package/text.cjs.map +1 -1
  137. package/text.d.ts +16 -0
  138. package/text.js +68 -37
  139. package/text.js.map +1 -1
  140. package/type-guard.cjs +292 -72
  141. package/type-guard.cjs.map +1 -1
  142. package/type-guard.d.ts +18 -0
  143. package/type-guard.js +288 -73
  144. package/type-guard.js.map +1 -1
  145. package/types.cjs +0 -2
  146. package/types.d.ts +41 -0
  147. package/types.global.cjs +0 -2
  148. package/types.global.d.ts +41 -0
  149. package/types.global.js +0 -2
  150. package/types.js +0 -2
  151. package/vibrate.cjs +47 -6
  152. package/vibrate.cjs.map +1 -1
  153. package/vibrate.d.ts +39 -1
  154. package/vibrate.js +48 -8
  155. package/vibrate.js.map +1 -1
  156. package/types.cjs.map +0 -1
  157. package/types.global.cjs.map +0 -1
  158. package/types.global.js.map +0 -1
  159. package/types.js.map +0 -1
package/complex.cjs CHANGED
@@ -1,139 +1,286 @@
1
- "use strict";
2
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const createCounter = (processValue, initial = 0) => {
4
- const update = (counter) => {
5
- fn.value = processValue?.(counter) ?? counter;
6
- return fn.value;
7
- };
8
- const increment = () => update(++fn.counter);
9
- const decrement = () => update(--fn.counter);
10
- const fn = increment;
11
- fn.increment = increment;
12
- fn.decrement = decrement;
13
- fn.reset = () => {
14
- fn.counter = initial;
15
- fn.value = processValue?.(initial) ?? initial;
16
- };
17
- fn.reset();
18
- return fn;
2
+ //#region src/complex/counter.ts
3
+ /**
4
+ * Creates a callable counter object with increment, decrement and reset helpers.
5
+ *
6
+ * The returned function increments the internal numeric counter when called and
7
+ * exposes both the raw counter value and an optionally transformed `value`.
8
+ *
9
+ * @template TValue Public value type returned by the counter.
10
+ * @param processValue Optional mapper that transforms the numeric counter value.
11
+ * @param initial Initial numeric counter value.
12
+ * @returns Callable counter with state and control methods.
13
+ *
14
+ * @example
15
+ * ```ts
16
+ * const counter = createCounter();
17
+ * counter.increment(); // 1
18
+ * ```
19
+ *
20
+ * @example
21
+ * ```ts
22
+ * const idCounter = createCounter((value) => `id-${value}`, 10);
23
+ * idCounter(); // 'id-11'
24
+ * ```
25
+ */
26
+ var createCounter = (processValue, initial = 0) => {
27
+ const update = (counter) => {
28
+ fn.value = processValue?.(counter) ?? counter;
29
+ return fn.value;
30
+ };
31
+ const increment = () => update(++fn.counter);
32
+ const decrement = () => update(--fn.counter);
33
+ const fn = increment;
34
+ fn.increment = increment;
35
+ fn.decrement = decrement;
36
+ fn.reset = () => {
37
+ fn.counter = initial;
38
+ fn.value = processValue?.(initial) ?? initial;
39
+ };
40
+ fn.reset();
41
+ return fn;
19
42
  };
20
- const createGlobalPoint = (accessSymbol) => {
21
- if (accessSymbol == null) {
22
- let storedValue;
23
- return {
24
- get: () => storedValue,
25
- unset: () => {
26
- storedValue = void 0;
27
- },
28
- set: (value) => {
29
- storedValue = value;
30
- return value;
31
- }
32
- };
33
- }
34
- const _globalThis = globalThis;
35
- return {
36
- get: () => _globalThis[accessSymbol],
37
- unset: () => {
38
- delete _globalThis[accessSymbol];
39
- },
40
- set: (value) => {
41
- _globalThis[accessSymbol] = value;
42
- return value;
43
- }
44
- };
43
+ //#endregion
44
+ //#region src/complex/global-point.ts
45
+ /**
46
+ * Creates a simple storage point that can live either in `globalThis` under a
47
+ * provided key or in a local closure when no key is given.
48
+ *
49
+ * @template TValue Stored value type.
50
+ * @param accessSymbol Optional global property name used for storage.
51
+ * @returns Getter/setter API for the stored value.
52
+ *
53
+ * @example
54
+ * ```ts
55
+ * const point = createGlobalPoint<number>();
56
+ * point.set(10);
57
+ * ```
58
+ *
59
+ * @example
60
+ * ```ts
61
+ * const point = createGlobalPoint<string>('__token__');
62
+ * point.get();
63
+ * ```
64
+ */
65
+ var createGlobalPoint = (accessSymbol) => {
66
+ if (accessSymbol == null) {
67
+ let storedValue;
68
+ return {
69
+ get: () => storedValue,
70
+ unset: () => {
71
+ storedValue = void 0;
72
+ },
73
+ set: (value) => {
74
+ storedValue = value;
75
+ return value;
76
+ }
77
+ };
78
+ }
79
+ const _globalThis = globalThis;
80
+ return {
81
+ get: () => _globalThis[accessSymbol],
82
+ unset: () => {
83
+ delete _globalThis[accessSymbol];
84
+ },
85
+ set: (value) => {
86
+ _globalThis[accessSymbol] = value;
87
+ return value;
88
+ }
89
+ };
45
90
  };
46
- const createGlobalConfig = (defaultValue, accessSymbol) => {
47
- const globalPoint = createGlobalPoint(accessSymbol);
48
- return globalPoint.get() || globalPoint.set(defaultValue);
91
+ //#endregion
92
+ //#region src/complex/global-config.ts
93
+ /**
94
+ * Creates or reuses a globally accessible config object.
95
+ *
96
+ * The config is stored in a global point identified by `accessSymbol`, or in a
97
+ * local closure when no symbol is provided.
98
+ *
99
+ * @template T Config object type.
100
+ * @param defaultValue Default value used when no config has been created yet.
101
+ * @param accessSymbol Optional global key used to store the config.
102
+ * @returns Existing or newly initialized global config object.
103
+ *
104
+ * @example
105
+ * ```ts
106
+ * const config = createGlobalConfig({ locale: 'en' }, '__app_config__');
107
+ * ```
108
+ *
109
+ * @example
110
+ * ```ts
111
+ * const config = createGlobalConfig({ debug: false });
112
+ * config.debug;
113
+ * ```
114
+ */
115
+ var createGlobalConfig = (defaultValue, accessSymbol) => {
116
+ const globalPoint = createGlobalPoint(accessSymbol);
117
+ return globalPoint.get() || globalPoint.set(defaultValue);
49
118
  };
50
- const createGlobalDynamicConfig = (processFn, accessSymbol) => {
51
- const globalPoint = createGlobalPoint(accessSymbol);
52
- const getValue = () => {
53
- return globalPoint.get() ?? globalPoint.set(processFn(null, null));
54
- };
55
- return {
56
- get: getValue,
57
- set: globalPoint.set,
58
- unset: globalPoint.unset,
59
- update: (value) => {
60
- const currentValue = getValue();
61
- Object.assign(currentValue, processFn(value, currentValue));
62
- }
63
- };
119
+ /**
120
+ * Creates a mutable global config manager whose value is produced and updated
121
+ * through a custom processor function.
122
+ *
123
+ * @template T Config object type.
124
+ * @param processFn Function that builds the next config state from a partial change and current value.
125
+ * @param accessSymbol Optional global key used to store the config.
126
+ * @returns API for reading, replacing, resetting and partially updating the config.
127
+ *
128
+ * @example
129
+ * ```ts
130
+ * const config = createGlobalDynamicConfig(
131
+ * (change, current) => ({ theme: 'light', ...current, ...change }),
132
+ * '__theme__',
133
+ * );
134
+ * ```
135
+ *
136
+ * @example
137
+ * ```ts
138
+ * const config = createGlobalDynamicConfig((change, current) => ({ ...current, ...change }));
139
+ * config.update({ locale: 'ru' });
140
+ * ```
141
+ */
142
+ var createGlobalDynamicConfig = (processFn, accessSymbol) => {
143
+ const globalPoint = createGlobalPoint(accessSymbol);
144
+ const getValue = () => {
145
+ return globalPoint.get() ?? globalPoint.set(processFn(null, null));
146
+ };
147
+ return {
148
+ get: getValue,
149
+ set: globalPoint.set,
150
+ unset: globalPoint.unset,
151
+ update: (value) => {
152
+ const currentValue = getValue();
153
+ Object.assign(currentValue, processFn(value, currentValue));
154
+ }
155
+ };
64
156
  };
65
- class ModulesFactory {
66
- /**
67
- * Creates a new module factory.
68
- *
69
- * @param config Factory strategy and predefined dependencies.
70
- *
71
- * @example
72
- * ```ts
73
- * const factory = new ModulesFactory({
74
- * factory: (Module, deps) => new Module(deps),
75
- * });
76
- * ```
77
- *
78
- * @example
79
- * ```ts
80
- * const factory = new ModulesFactory({
81
- * factory: (Module, deps) => new Module(deps),
82
- * deps: { api },
83
- * });
84
- * ```
85
- */
86
- constructor(config) {
87
- this.config = config;
88
- }
89
- /**
90
- * Creates an instance of the provided class by merging predefined and
91
- * per-call dependencies.
92
- *
93
- * @template TInstance Instance type produced by the constructor.
94
- * @template TDeps Full dependency object expected by the constructor.
95
- * @param Constructor Class constructor receiving a single dependency object.
96
- * @param args Additional dependencies merged over predefined ones.
97
- * @returns Created class instance.
98
- *
99
- * @example
100
- * ```ts
101
- * const service = factory.create(UserService, { logger });
102
- * ```
103
- *
104
- * @example
105
- * ```ts
106
- * const store = factory.create(UserStore);
107
- * ```
108
- */
109
- create(Constructor, ...args) {
110
- return this.config.factory(Constructor, {
111
- ...this.config.deps,
112
- ...args[0]
113
- });
114
- }
115
- }
116
- const createPubSub = () => {
117
- const pubSub = ((...args) => {
118
- pubSub.lastPub = args;
119
- pubSub.subs.forEach((sub) => {
120
- sub(...args);
121
- });
122
- });
123
- pubSub.lastPub = void 0;
124
- pubSub.subs = [];
125
- pubSub.unsub = (sub) => {
126
- pubSub.subs = pubSub.subs.filter((it) => it !== sub);
127
- };
128
- pubSub.sub = (sub) => {
129
- pubSub.subs.push(sub);
130
- return () => pubSub.unsub(sub);
131
- };
132
- return pubSub;
157
+ //#endregion
158
+ //#region src/complex/modules-factory.ts
159
+ /**
160
+ * Universal factory for creating class instances with predefined and per-call
161
+ * dependencies.
162
+ *
163
+ * Works with classes whose constructor accepts a single dependency object.
164
+ *
165
+ * @template TPredefinedDeps Dependency shape that is always injected by the factory.
166
+ *
167
+ * @example
168
+ * ```
169
+ * const factory = new ModulesFactory({
170
+ * factory: (MyClass, deps) => new MyClass(deps),
171
+ * deps: { someDependency: new Dependency() }
172
+ * });
173
+ *
174
+ * const instance = factory.create(MyClass, { extraDependency: new ExtraDependency() });
175
+ * ```
176
+ *
177
+ * @example
178
+ * ```ts
179
+ * const factory = new ModulesFactory({
180
+ * factory: (Module, deps) => new Module(deps),
181
+ * });
182
+ * ```
183
+ *
184
+ * @example
185
+ * ```ts
186
+ * const service = factory.create(UserService, { api });
187
+ * ```
188
+ */
189
+ var ModulesFactory = class {
190
+ /**
191
+ * Creates a new module factory.
192
+ *
193
+ * @param config Factory strategy and predefined dependencies.
194
+ *
195
+ * @example
196
+ * ```ts
197
+ * const factory = new ModulesFactory({
198
+ * factory: (Module, deps) => new Module(deps),
199
+ * });
200
+ * ```
201
+ *
202
+ * @example
203
+ * ```ts
204
+ * const factory = new ModulesFactory({
205
+ * factory: (Module, deps) => new Module(deps),
206
+ * deps: { api },
207
+ * });
208
+ * ```
209
+ */
210
+ constructor(config) {
211
+ this.config = config;
212
+ }
213
+ /**
214
+ * Creates an instance of the provided class by merging predefined and
215
+ * per-call dependencies.
216
+ *
217
+ * @template TInstance Instance type produced by the constructor.
218
+ * @template TDeps Full dependency object expected by the constructor.
219
+ * @param Constructor Class constructor receiving a single dependency object.
220
+ * @param args Additional dependencies merged over predefined ones.
221
+ * @returns Created class instance.
222
+ *
223
+ * @example
224
+ * ```ts
225
+ * const service = factory.create(UserService, { logger });
226
+ * ```
227
+ *
228
+ * @example
229
+ * ```ts
230
+ * const store = factory.create(UserStore);
231
+ * ```
232
+ */
233
+ create(Constructor, ...args) {
234
+ return this.config.factory(Constructor, {
235
+ ...this.config.deps,
236
+ ...args[0]
237
+ });
238
+ }
133
239
  };
240
+ //#endregion
241
+ //#region src/complex/pub-sub.ts
242
+ /**
243
+ * Creates a simple publish-subscribe dispatcher that stores the last published
244
+ * arguments and allows subscription management.
245
+ *
246
+ * @template PubArgs Argument tuple delivered to subscribers.
247
+ * @returns Callable publisher with subscribe and unsubscribe helpers.
248
+ *
249
+ * @example
250
+ * ```ts
251
+ * const pub = createPubSub<[string]>();
252
+ * pub('ready');
253
+ * ```
254
+ *
255
+ * @example
256
+ * ```ts
257
+ * const pub = createPubSub<[number]>();
258
+ * const unsub = pub.sub((value) => console.log(value));
259
+ * ```
260
+ */
261
+ var createPubSub = () => {
262
+ const pubSub = ((...args) => {
263
+ pubSub.lastPub = args;
264
+ pubSub.subs.forEach((sub) => {
265
+ sub(...args);
266
+ });
267
+ });
268
+ pubSub.lastPub = void 0;
269
+ pubSub.subs = [];
270
+ pubSub.unsub = (sub) => {
271
+ pubSub.subs = pubSub.subs.filter((it) => it !== sub);
272
+ };
273
+ pubSub.sub = (sub) => {
274
+ pubSub.subs.push(sub);
275
+ return () => pubSub.unsub(sub);
276
+ };
277
+ return pubSub;
278
+ };
279
+ //#endregion
134
280
  exports.ModulesFactory = ModulesFactory;
135
281
  exports.createCounter = createCounter;
136
282
  exports.createGlobalConfig = createGlobalConfig;
137
283
  exports.createGlobalDynamicConfig = createGlobalDynamicConfig;
138
284
  exports.createPubSub = createPubSub;
139
- //# sourceMappingURL=complex.cjs.map
285
+
286
+ //# sourceMappingURL=complex.cjs.map
package/complex.cjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"complex.cjs","sources":["../src/complex/counter.ts","../src/complex/global-point.ts","../src/complex/global-config.ts","../src/complex/modules-factory.ts","../src/complex/pub-sub.ts"],"sourcesContent":["export interface Counter<TValue = number> {\n (): TValue;\n counter: number;\n value: TValue;\n increment(): TValue;\n decrement(): TValue;\n reset(): void;\n}\n\n/**\n * @deprecated use {`Counter`}. Will be removed in next major release\n */\nexport interface CounterFn<TValue = number> extends Counter<TValue> {}\n\n/**\n * Creates a callable counter object with increment, decrement and reset helpers.\n *\n * The returned function increments the internal numeric counter when called and\n * exposes both the raw counter value and an optionally transformed `value`.\n *\n * @template TValue Public value type returned by the counter.\n * @param processValue Optional mapper that transforms the numeric counter value.\n * @param initial Initial numeric counter value.\n * @returns Callable counter with state and control methods.\n *\n * @example\n * ```ts\n * const counter = createCounter();\n * counter.increment(); // 1\n * ```\n *\n * @example\n * ```ts\n * const idCounter = createCounter((value) => `id-${value}`, 10);\n * idCounter(); // 'id-11'\n * ```\n */\nexport const createCounter = <TValue = number>(\n processValue?: (value: number) => TValue,\n initial: number = 0,\n): Counter<TValue> => {\n const update = (counter: number) => {\n fn.value = processValue?.(counter) ?? (counter as TValue);\n return fn.value;\n };\n\n const increment = () => update(++fn.counter);\n const decrement = () => update(--fn.counter);\n\n const fn: Counter<TValue> = increment as any;\n\n fn.increment = increment;\n fn.decrement = decrement;\n\n fn.reset = () => {\n fn.counter = initial;\n fn.value = processValue?.(initial) ?? (initial as TValue);\n };\n\n fn.reset();\n\n return fn as Counter<TValue>;\n};\n","import type { AnyObject } from 'yummies/types';\n\nexport interface GlobalPoint<TValue> {\n get(): TValue;\n set(value: TValue): TValue;\n unset(): void;\n}\n\n/**\n * Creates a simple storage point that can live either in `globalThis` under a\n * provided key or in a local closure when no key is given.\n *\n * @template TValue Stored value type.\n * @param accessSymbol Optional global property name used for storage.\n * @returns Getter/setter API for the stored value.\n *\n * @example\n * ```ts\n * const point = createGlobalPoint<number>();\n * point.set(10);\n * ```\n *\n * @example\n * ```ts\n * const point = createGlobalPoint<string>('__token__');\n * point.get();\n * ```\n */\nexport const createGlobalPoint = <TValue>(\n accessSymbol?: keyof any,\n): GlobalPoint<TValue> => {\n if (accessSymbol == null) {\n let storedValue: TValue | undefined;\n\n return {\n get: (): TValue => storedValue!,\n unset: () => {\n storedValue = undefined;\n },\n set: (value: TValue): TValue => {\n storedValue = value;\n return value;\n },\n };\n }\n\n const _globalThis = globalThis as AnyObject;\n\n return {\n get: (): TValue => _globalThis[accessSymbol],\n unset: () => {\n delete _globalThis[accessSymbol];\n },\n set: (value: TValue): TValue => {\n _globalThis[accessSymbol] = value;\n return value;\n },\n };\n};\n","import type { AnyObject, Maybe } from 'yummies/types';\nimport { createGlobalPoint } from './global-point.js';\n\n/**\n * Creates or reuses a globally accessible config object.\n *\n * The config is stored in a global point identified by `accessSymbol`, or in a\n * local closure when no symbol is provided.\n *\n * @template T Config object type.\n * @param defaultValue Default value used when no config has been created yet.\n * @param accessSymbol Optional global key used to store the config.\n * @returns Existing or newly initialized global config object.\n *\n * @example\n * ```ts\n * const config = createGlobalConfig({ locale: 'en' }, '__app_config__');\n * ```\n *\n * @example\n * ```ts\n * const config = createGlobalConfig({ debug: false });\n * config.debug;\n * ```\n */\nexport const createGlobalConfig = <T extends AnyObject>(\n defaultValue: T,\n accessSymbol?: keyof any,\n): T => {\n const globalPoint = createGlobalPoint<T>(accessSymbol);\n return globalPoint.get() || globalPoint.set(defaultValue);\n};\n\nexport interface GlobalDynamicConfig<TValue extends AnyObject> {\n get(): TValue;\n set(value: TValue): TValue;\n unset(): void;\n update(value: Partial<TValue>): void;\n}\n\n/**\n * Creates a mutable global config manager whose value is produced and updated\n * through a custom processor function.\n *\n * @template T Config object type.\n * @param processFn Function that builds the next config state from a partial change and current value.\n * @param accessSymbol Optional global key used to store the config.\n * @returns API for reading, replacing, resetting and partially updating the config.\n *\n * @example\n * ```ts\n * const config = createGlobalDynamicConfig(\n * (change, current) => ({ theme: 'light', ...current, ...change }),\n * '__theme__',\n * );\n * ```\n *\n * @example\n * ```ts\n * const config = createGlobalDynamicConfig((change, current) => ({ ...current, ...change }));\n * config.update({ locale: 'ru' });\n * ```\n */\nexport const createGlobalDynamicConfig = <T extends AnyObject>(\n processFn: (change: Maybe<Partial<T>>, current: Maybe<T>) => T,\n accessSymbol?: keyof any,\n): GlobalDynamicConfig<T> => {\n const globalPoint = createGlobalPoint<T>(accessSymbol);\n\n const getValue = () => {\n return globalPoint.get() ?? globalPoint.set(processFn(null, null))!;\n };\n\n return {\n get: getValue,\n set: globalPoint.set,\n unset: globalPoint.unset,\n update: (value: Partial<T>) => {\n const currentValue = getValue();\n Object.assign(currentValue, processFn(value, currentValue));\n },\n };\n};\n","import type { AnyObject, Class, EmptyObject, IsPartial } from 'yummies/types';\n\ntype ModuleLoaderConfig<TPredefinedDeps extends AnyObject = EmptyObject> = {\n factory<TInstance, TDeps extends TPredefinedDeps>(\n moduleClass: Class<TInstance, [TDeps]>,\n deps: TDeps,\n ): TInstance;\n} & (TPredefinedDeps extends EmptyObject\n ? { deps?: TPredefinedDeps }\n : { deps: TPredefinedDeps });\n\n/**\n * Universal factory for creating class instances with predefined and per-call\n * dependencies.\n *\n * Works with classes whose constructor accepts a single dependency object.\n *\n * @template TPredefinedDeps Dependency shape that is always injected by the factory.\n *\n * @example\n * ```\n * const factory = new ModulesFactory({\n * factory: (MyClass, deps) => new MyClass(deps),\n * deps: { someDependency: new Dependency() }\n * });\n *\n * const instance = factory.create(MyClass, { extraDependency: new ExtraDependency() });\n * ```\n *\n * @example\n * ```ts\n * const factory = new ModulesFactory({\n * factory: (Module, deps) => new Module(deps),\n * });\n * ```\n *\n * @example\n * ```ts\n * const service = factory.create(UserService, { api });\n * ```\n */\nexport class ModulesFactory<TPredefinedDeps extends AnyObject = EmptyObject> {\n /**\n * Creates a new module factory.\n *\n * @param config Factory strategy and predefined dependencies.\n *\n * @example\n * ```ts\n * const factory = new ModulesFactory({\n * factory: (Module, deps) => new Module(deps),\n * });\n * ```\n *\n * @example\n * ```ts\n * const factory = new ModulesFactory({\n * factory: (Module, deps) => new Module(deps),\n * deps: { api },\n * });\n * ```\n */\n constructor(private config: ModuleLoaderConfig<TPredefinedDeps>) {}\n\n /**\n * Creates an instance of the provided class by merging predefined and\n * per-call dependencies.\n *\n * @template TInstance Instance type produced by the constructor.\n * @template TDeps Full dependency object expected by the constructor.\n * @param Constructor Class constructor receiving a single dependency object.\n * @param args Additional dependencies merged over predefined ones.\n * @returns Created class instance.\n *\n * @example\n * ```ts\n * const service = factory.create(UserService, { logger });\n * ```\n *\n * @example\n * ```ts\n * const store = factory.create(UserStore);\n * ```\n */\n create<TInstance, TDeps extends TPredefinedDeps = TPredefinedDeps>(\n Constructor: Class<TInstance, [TDeps]>,\n ...args: IsPartial<Omit<TDeps, keyof TPredefinedDeps>> extends true\n ? [extraDeps?: Omit<TDeps, keyof TPredefinedDeps>]\n : [extraDeps: Omit<TDeps, keyof TPredefinedDeps>]\n ) {\n return this.config.factory(Constructor, {\n ...this.config.deps!,\n ...args[0],\n } as any);\n }\n}\n","export type SubFn<PubArgs extends any[] = any[]> = (...args: PubArgs) => void;\n\n/**\n * The Publish-Subscribe pattern, which allows objects to interact with each other\n * through an event system. Subscribers can subscribe to events and receive notifications\n * when these events occur. The last published data can be accessed through the `data` property.\n */\nexport interface PubSub<PubArgs extends any[] = any[]> {\n (...args: PubArgs): void;\n\n /**\n * Last published arguments\n */\n lastPub: PubArgs | undefined;\n\n /**\n * An array of subscriber functions (sub) that will be called\n * when an event is published. Each subscriber must match the type SubFn,\n * taking the arguments that will be passed to it when the publisher calls pub.\n */\n subs: SubFn<PubArgs>[];\n\n /**\n * A function to unsubscribe from events. When a subscriber function (sub) is passed,\n * it will be removed from the `subs` array, and will no longer receive notifications.\n */\n unsub(sub: SubFn<PubArgs>): void;\n /**\n * A function to subscribe to events. When a subscriber function (sub) is passed,\n * it will be added to the `subs` array, and will receive notifications when the publisher calls pub.\n * Returns a function that can be used to unsubscribe from events.\n */\n sub(sub: SubFn<PubArgs>): VoidFunction;\n}\n\n/**\n * Creates a simple publish-subscribe dispatcher that stores the last published\n * arguments and allows subscription management.\n *\n * @template PubArgs Argument tuple delivered to subscribers.\n * @returns Callable publisher with subscribe and unsubscribe helpers.\n *\n * @example\n * ```ts\n * const pub = createPubSub<[string]>();\n * pub('ready');\n * ```\n *\n * @example\n * ```ts\n * const pub = createPubSub<[number]>();\n * const unsub = pub.sub((value) => console.log(value));\n * ```\n */\nexport const createPubSub = <PubArgs extends any[] = any[]>() => {\n const pubSub = ((...args: PubArgs) => {\n pubSub.lastPub = args;\n pubSub.subs.forEach((sub) => {\n sub(...args);\n });\n }) as PubSub<PubArgs>;\n pubSub.lastPub = undefined;\n\n pubSub.subs = [];\n\n pubSub.unsub = (sub: SubFn<PubArgs>) => {\n pubSub.subs = pubSub.subs.filter((it) => it !== sub);\n };\n pubSub.sub = (sub: SubFn<PubArgs>) => {\n pubSub.subs.push(sub);\n return () => pubSub.unsub(sub);\n };\n\n return pubSub;\n};\n"],"names":[],"mappings":";;AAqCO,MAAM,gBAAgB,CAC3B,cACA,UAAkB,MACE;AACpB,QAAM,SAAS,CAAC,YAAoB;AAClC,OAAG,QAAQ,eAAe,OAAO,KAAM;AACvC,WAAO,GAAG;AAAA,EACZ;AAEA,QAAM,YAAY,MAAM,OAAO,EAAE,GAAG,OAAO;AAC3C,QAAM,YAAY,MAAM,OAAO,EAAE,GAAG,OAAO;AAE3C,QAAM,KAAsB;AAE5B,KAAG,YAAY;AACf,KAAG,YAAY;AAEf,KAAG,QAAQ,MAAM;AACf,OAAG,UAAU;AACb,OAAG,QAAQ,eAAe,OAAO,KAAM;AAAA,EACzC;AAEA,KAAG,MAAA;AAEH,SAAO;AACT;AClCO,MAAM,oBAAoB,CAC/B,iBACwB;AACxB,MAAI,gBAAgB,MAAM;AACxB,QAAI;AAEJ,WAAO;AAAA,MACL,KAAK,MAAc;AAAA,MACnB,OAAO,MAAM;AACX,sBAAc;AAAA,MAChB;AAAA,MACA,KAAK,CAAC,UAA0B;AAC9B,sBAAc;AACd,eAAO;AAAA,MACT;AAAA,IAAA;AAAA,EAEJ;AAEA,QAAM,cAAc;AAEpB,SAAO;AAAA,IACL,KAAK,MAAc,YAAY,YAAY;AAAA,IAC3C,OAAO,MAAM;AACX,aAAO,YAAY,YAAY;AAAA,IACjC;AAAA,IACA,KAAK,CAAC,UAA0B;AAC9B,kBAAY,YAAY,IAAI;AAC5B,aAAO;AAAA,IACT;AAAA,EAAA;AAEJ;ACjCO,MAAM,qBAAqB,CAChC,cACA,iBACM;AACN,QAAM,cAAc,kBAAqB,YAAY;AACrD,SAAO,YAAY,IAAA,KAAS,YAAY,IAAI,YAAY;AAC1D;AAgCO,MAAM,4BAA4B,CACvC,WACA,iBAC2B;AAC3B,QAAM,cAAc,kBAAqB,YAAY;AAErD,QAAM,WAAW,MAAM;AACrB,WAAO,YAAY,SAAS,YAAY,IAAI,UAAU,MAAM,IAAI,CAAC;AAAA,EACnE;AAEA,SAAO;AAAA,IACL,KAAK;AAAA,IACL,KAAK,YAAY;AAAA,IACjB,OAAO,YAAY;AAAA,IACnB,QAAQ,CAAC,UAAsB;AAC7B,YAAM,eAAe,SAAA;AACrB,aAAO,OAAO,cAAc,UAAU,OAAO,YAAY,CAAC;AAAA,IAC5D;AAAA,EAAA;AAEJ;ACzCO,MAAM,eAAgE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAqB3E,YAAoB,QAA6C;AAA7C,SAAA,SAAA;AAAA,EAA8C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAsBlE,OACE,gBACG,MAGH;AACA,WAAO,KAAK,OAAO,QAAQ,aAAa;AAAA,MACtC,GAAG,KAAK,OAAO;AAAA,MACf,GAAG,KAAK,CAAC;AAAA,IAAA,CACH;AAAA,EACV;AACF;ACzCO,MAAM,eAAe,MAAqC;AAC/D,QAAM,UAAU,IAAI,SAAkB;AACpC,WAAO,UAAU;AACjB,WAAO,KAAK,QAAQ,CAAC,QAAQ;AAC3B,UAAI,GAAG,IAAI;AAAA,IACb,CAAC;AAAA,EACH;AACA,SAAO,UAAU;AAEjB,SAAO,OAAO,CAAA;AAEd,SAAO,QAAQ,CAAC,QAAwB;AACtC,WAAO,OAAO,OAAO,KAAK,OAAO,CAAC,OAAO,OAAO,GAAG;AAAA,EACrD;AACA,SAAO,MAAM,CAAC,QAAwB;AACpC,WAAO,KAAK,KAAK,GAAG;AACpB,WAAO,MAAM,OAAO,MAAM,GAAG;AAAA,EAC/B;AAEA,SAAO;AACT;;;;;;"}
1
+ {"version":3,"file":"complex.cjs","names":[],"sources":["../src/complex/counter.ts","../src/complex/global-point.ts","../src/complex/global-config.ts","../src/complex/modules-factory.ts","../src/complex/pub-sub.ts"],"sourcesContent":["/**\n * ---header-docs-section---\n * # yummies/complex\n *\n * ## Description\n *\n * Callable **counter** objects with increment, decrement, and reset for UI steppers, pagination,\n * and id generators. Values can be mapped on read so the public API stays typed while the internal\n * tick stays numeric. This file is the `counter` slice of the broader `yummies/complex` entry point.\n *\n * ## Usage\n *\n * ```ts\n * import { createCounter } from \"yummies/complex\";\n * ```\n */\n\nexport interface Counter<TValue = number> {\n (): TValue;\n counter: number;\n value: TValue;\n increment(): TValue;\n decrement(): TValue;\n reset(): void;\n}\n\n/**\n * @deprecated use {`Counter`}. Will be removed in next major release\n */\nexport interface CounterFn<TValue = number> extends Counter<TValue> {}\n\n/**\n * Creates a callable counter object with increment, decrement and reset helpers.\n *\n * The returned function increments the internal numeric counter when called and\n * exposes both the raw counter value and an optionally transformed `value`.\n *\n * @template TValue Public value type returned by the counter.\n * @param processValue Optional mapper that transforms the numeric counter value.\n * @param initial Initial numeric counter value.\n * @returns Callable counter with state and control methods.\n *\n * @example\n * ```ts\n * const counter = createCounter();\n * counter.increment(); // 1\n * ```\n *\n * @example\n * ```ts\n * const idCounter = createCounter((value) => `id-${value}`, 10);\n * idCounter(); // 'id-11'\n * ```\n */\nexport const createCounter = <TValue = number>(\n processValue?: (value: number) => TValue,\n initial: number = 0,\n): Counter<TValue> => {\n const update = (counter: number) => {\n fn.value = processValue?.(counter) ?? (counter as TValue);\n return fn.value;\n };\n\n const increment = () => update(++fn.counter);\n const decrement = () => update(--fn.counter);\n\n const fn: Counter<TValue> = increment as any;\n\n fn.increment = increment;\n fn.decrement = decrement;\n\n fn.reset = () => {\n fn.counter = initial;\n fn.value = processValue?.(initial) ?? (initial as TValue);\n };\n\n fn.reset();\n\n return fn as Counter<TValue>;\n};\n","/**\n * ---header-docs-section---\n * # yummies/complex\n *\n * ## Description\n *\n * Minimal **global or scoped storage** with `get` / `set` / `unset` semantics. When an access symbol\n * is provided the value lives on `globalThis`; otherwise it is isolated in a closure. Handy for\n * bridging non-React singletons, test doubles, or legacy globals without `window.foo =` sprawl.\n *\n * ## Usage\n *\n * ```ts\n * import { createGlobalPoint } from \"yummies/complex\";\n * ```\n */\n\nimport type { AnyObject } from 'yummies/types';\n\nexport interface GlobalPoint<TValue> {\n get(): TValue;\n set(value: TValue): TValue;\n unset(): void;\n}\n\n/**\n * Creates a simple storage point that can live either in `globalThis` under a\n * provided key or in a local closure when no key is given.\n *\n * @template TValue Stored value type.\n * @param accessSymbol Optional global property name used for storage.\n * @returns Getter/setter API for the stored value.\n *\n * @example\n * ```ts\n * const point = createGlobalPoint<number>();\n * point.set(10);\n * ```\n *\n * @example\n * ```ts\n * const point = createGlobalPoint<string>('__token__');\n * point.get();\n * ```\n */\nexport const createGlobalPoint = <TValue>(\n accessSymbol?: keyof any,\n): GlobalPoint<TValue> => {\n if (accessSymbol == null) {\n let storedValue: TValue | undefined;\n\n return {\n get: (): TValue => storedValue!,\n unset: () => {\n storedValue = undefined;\n },\n set: (value: TValue): TValue => {\n storedValue = value;\n return value;\n },\n };\n }\n\n const _globalThis = globalThis as AnyObject;\n\n return {\n get: (): TValue => _globalThis[accessSymbol],\n unset: () => {\n delete _globalThis[accessSymbol];\n },\n set: (value: TValue): TValue => {\n _globalThis[accessSymbol] = value;\n return value;\n },\n };\n};\n","/**\n * ---header-docs-section---\n * # yummies/complex\n *\n * ## Description\n *\n * **Singleton-style config** backed by either `globalThis` (keyed by symbol) or a module closure.\n * Use for app-wide feature flags, bootstrapped locale, or SSR-safe defaults without prop-drilling.\n * Pairs with `createGlobalPoint` for other global handles in the same `yummies/complex` package.\n *\n * ## Usage\n *\n * ```ts\n * import { createGlobalConfig } from \"yummies/complex\";\n * ```\n */\n\nimport type { AnyObject, Maybe } from 'yummies/types';\nimport { createGlobalPoint } from './global-point.js';\n\n/**\n * Creates or reuses a globally accessible config object.\n *\n * The config is stored in a global point identified by `accessSymbol`, or in a\n * local closure when no symbol is provided.\n *\n * @template T Config object type.\n * @param defaultValue Default value used when no config has been created yet.\n * @param accessSymbol Optional global key used to store the config.\n * @returns Existing or newly initialized global config object.\n *\n * @example\n * ```ts\n * const config = createGlobalConfig({ locale: 'en' }, '__app_config__');\n * ```\n *\n * @example\n * ```ts\n * const config = createGlobalConfig({ debug: false });\n * config.debug;\n * ```\n */\nexport const createGlobalConfig = <T extends AnyObject>(\n defaultValue: T,\n accessSymbol?: keyof any,\n): T => {\n const globalPoint = createGlobalPoint<T>(accessSymbol);\n return globalPoint.get() || globalPoint.set(defaultValue);\n};\n\nexport interface GlobalDynamicConfig<TValue extends AnyObject> {\n get(): TValue;\n set(value: TValue): TValue;\n unset(): void;\n update(value: Partial<TValue>): void;\n}\n\n/**\n * Creates a mutable global config manager whose value is produced and updated\n * through a custom processor function.\n *\n * @template T Config object type.\n * @param processFn Function that builds the next config state from a partial change and current value.\n * @param accessSymbol Optional global key used to store the config.\n * @returns API for reading, replacing, resetting and partially updating the config.\n *\n * @example\n * ```ts\n * const config = createGlobalDynamicConfig(\n * (change, current) => ({ theme: 'light', ...current, ...change }),\n * '__theme__',\n * );\n * ```\n *\n * @example\n * ```ts\n * const config = createGlobalDynamicConfig((change, current) => ({ ...current, ...change }));\n * config.update({ locale: 'ru' });\n * ```\n */\nexport const createGlobalDynamicConfig = <T extends AnyObject>(\n processFn: (change: Maybe<Partial<T>>, current: Maybe<T>) => T,\n accessSymbol?: keyof any,\n): GlobalDynamicConfig<T> => {\n const globalPoint = createGlobalPoint<T>(accessSymbol);\n\n const getValue = () => {\n return globalPoint.get() ?? globalPoint.set(processFn(null, null))!;\n };\n\n return {\n get: getValue,\n set: globalPoint.set,\n unset: globalPoint.unset,\n update: (value: Partial<T>) => {\n const currentValue = getValue();\n Object.assign(currentValue, processFn(value, currentValue));\n },\n };\n};\n","/**\n * ---header-docs-section---\n * # yummies/complex\n *\n * ## Description\n *\n * **Dependency-injection style factory** for classes that take a single deps object in their\n * constructor. Merges predefined singletons with per-call overrides so feature modules can be\n * constructed consistently in apps that avoid heavyweight DI containers.\n *\n * ## Usage\n *\n * ```ts\n * import { ModulesFactory } from \"yummies/complex\";\n * ```\n */\n\nimport type { AnyObject, Class, EmptyObject, IsPartial } from 'yummies/types';\n\ntype ModuleLoaderConfig<TPredefinedDeps extends AnyObject = EmptyObject> = {\n factory<TInstance, TDeps extends TPredefinedDeps>(\n moduleClass: Class<TInstance, [TDeps]>,\n deps: TDeps,\n ): TInstance;\n} & (TPredefinedDeps extends EmptyObject\n ? { deps?: TPredefinedDeps }\n : { deps: TPredefinedDeps });\n\n/**\n * Universal factory for creating class instances with predefined and per-call\n * dependencies.\n *\n * Works with classes whose constructor accepts a single dependency object.\n *\n * @template TPredefinedDeps Dependency shape that is always injected by the factory.\n *\n * @example\n * ```\n * const factory = new ModulesFactory({\n * factory: (MyClass, deps) => new MyClass(deps),\n * deps: { someDependency: new Dependency() }\n * });\n *\n * const instance = factory.create(MyClass, { extraDependency: new ExtraDependency() });\n * ```\n *\n * @example\n * ```ts\n * const factory = new ModulesFactory({\n * factory: (Module, deps) => new Module(deps),\n * });\n * ```\n *\n * @example\n * ```ts\n * const service = factory.create(UserService, { api });\n * ```\n */\nexport class ModulesFactory<TPredefinedDeps extends AnyObject = EmptyObject> {\n /**\n * Creates a new module factory.\n *\n * @param config Factory strategy and predefined dependencies.\n *\n * @example\n * ```ts\n * const factory = new ModulesFactory({\n * factory: (Module, deps) => new Module(deps),\n * });\n * ```\n *\n * @example\n * ```ts\n * const factory = new ModulesFactory({\n * factory: (Module, deps) => new Module(deps),\n * deps: { api },\n * });\n * ```\n */\n constructor(private config: ModuleLoaderConfig<TPredefinedDeps>) {}\n\n /**\n * Creates an instance of the provided class by merging predefined and\n * per-call dependencies.\n *\n * @template TInstance Instance type produced by the constructor.\n * @template TDeps Full dependency object expected by the constructor.\n * @param Constructor Class constructor receiving a single dependency object.\n * @param args Additional dependencies merged over predefined ones.\n * @returns Created class instance.\n *\n * @example\n * ```ts\n * const service = factory.create(UserService, { logger });\n * ```\n *\n * @example\n * ```ts\n * const store = factory.create(UserStore);\n * ```\n */\n create<TInstance, TDeps extends TPredefinedDeps = TPredefinedDeps>(\n Constructor: Class<TInstance, [TDeps]>,\n ...args: IsPartial<Omit<TDeps, keyof TPredefinedDeps>> extends true\n ? [extraDeps?: Omit<TDeps, keyof TPredefinedDeps>]\n : [extraDeps: Omit<TDeps, keyof TPredefinedDeps>]\n ) {\n return this.config.factory(Constructor, {\n ...this.config.deps!,\n ...args[0],\n } as any);\n }\n}\n","/**\n * ---header-docs-section---\n * # yummies/complex\n *\n * ## Description\n *\n * Tiny **publish–subscribe** bus: subscribers register callbacks, publishers broadcast arguments, and\n * the last payload remains readable for late subscribers. Simpler than full event emitters when you\n * only need in-memory fan-out inside a feature or view-model layer.\n *\n * ## Usage\n *\n * ```ts\n * import { createPubSub } from \"yummies/complex\";\n * ```\n */\n\nexport type SubFn<PubArgs extends any[] = any[]> = (...args: PubArgs) => void;\n\n/**\n * The Publish-Subscribe pattern, which allows objects to interact with each other\n * through an event system. Subscribers can subscribe to events and receive notifications\n * when these events occur. The last published data can be accessed through the `data` property.\n */\nexport interface PubSub<PubArgs extends any[] = any[]> {\n (...args: PubArgs): void;\n\n /**\n * Last published arguments\n */\n lastPub: PubArgs | undefined;\n\n /**\n * An array of subscriber functions (sub) that will be called\n * when an event is published. Each subscriber must match the type SubFn,\n * taking the arguments that will be passed to it when the publisher calls pub.\n */\n subs: SubFn<PubArgs>[];\n\n /**\n * A function to unsubscribe from events. When a subscriber function (sub) is passed,\n * it will be removed from the `subs` array, and will no longer receive notifications.\n */\n unsub(sub: SubFn<PubArgs>): void;\n /**\n * A function to subscribe to events. When a subscriber function (sub) is passed,\n * it will be added to the `subs` array, and will receive notifications when the publisher calls pub.\n * Returns a function that can be used to unsubscribe from events.\n */\n sub(sub: SubFn<PubArgs>): VoidFunction;\n}\n\n/**\n * Creates a simple publish-subscribe dispatcher that stores the last published\n * arguments and allows subscription management.\n *\n * @template PubArgs Argument tuple delivered to subscribers.\n * @returns Callable publisher with subscribe and unsubscribe helpers.\n *\n * @example\n * ```ts\n * const pub = createPubSub<[string]>();\n * pub('ready');\n * ```\n *\n * @example\n * ```ts\n * const pub = createPubSub<[number]>();\n * const unsub = pub.sub((value) => console.log(value));\n * ```\n */\nexport const createPubSub = <PubArgs extends any[] = any[]>() => {\n const pubSub = ((...args: PubArgs) => {\n pubSub.lastPub = args;\n pubSub.subs.forEach((sub) => {\n sub(...args);\n });\n }) as PubSub<PubArgs>;\n pubSub.lastPub = undefined;\n\n pubSub.subs = [];\n\n pubSub.unsub = (sub: SubFn<PubArgs>) => {\n pubSub.subs = pubSub.subs.filter((it) => it !== sub);\n };\n pubSub.sub = (sub: SubFn<PubArgs>) => {\n pubSub.subs.push(sub);\n return () => pubSub.unsub(sub);\n };\n\n return pubSub;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAsDA,IAAa,iBACX,cACA,UAAkB,MACE;CACpB,MAAM,UAAU,YAAoB;AAClC,KAAG,QAAQ,eAAe,QAAQ,IAAK;AACvC,SAAO,GAAG;;CAGZ,MAAM,kBAAkB,OAAO,EAAE,GAAG,QAAQ;CAC5C,MAAM,kBAAkB,OAAO,EAAE,GAAG,QAAQ;CAE5C,MAAM,KAAsB;AAE5B,IAAG,YAAY;AACf,IAAG,YAAY;AAEf,IAAG,cAAc;AACf,KAAG,UAAU;AACb,KAAG,QAAQ,eAAe,QAAQ,IAAK;;AAGzC,IAAG,OAAO;AAEV,QAAO;;;;;;;;;;;;;;;;;;;;;;;;ACjCT,IAAa,qBACX,iBACwB;AACxB,KAAI,gBAAgB,MAAM;EACxB,IAAI;AAEJ,SAAO;GACL,WAAmB;GACnB,aAAa;AACX,kBAAc,KAAA;;GAEhB,MAAM,UAA0B;AAC9B,kBAAc;AACd,WAAO;;GAEV;;CAGH,MAAM,cAAc;AAEpB,QAAO;EACL,WAAmB,YAAY;EAC/B,aAAa;AACX,UAAO,YAAY;;EAErB,MAAM,UAA0B;AAC9B,eAAY,gBAAgB;AAC5B,UAAO;;EAEV;;;;;;;;;;;;;;;;;;;;;;;;;;AChCH,IAAa,sBACX,cACA,iBACM;CACN,MAAM,cAAc,kBAAqB,aAAa;AACtD,QAAO,YAAY,KAAK,IAAI,YAAY,IAAI,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;AAiC3D,IAAa,6BACX,WACA,iBAC2B;CAC3B,MAAM,cAAc,kBAAqB,aAAa;CAEtD,MAAM,iBAAiB;AACrB,SAAO,YAAY,KAAK,IAAI,YAAY,IAAI,UAAU,MAAM,KAAK,CAAC;;AAGpE,QAAO;EACL,KAAK;EACL,KAAK,YAAY;EACjB,OAAO,YAAY;EACnB,SAAS,UAAsB;GAC7B,MAAM,eAAe,UAAU;AAC/B,UAAO,OAAO,cAAc,UAAU,OAAO,aAAa,CAAC;;EAE9D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACxCH,IAAa,iBAAb,MAA6E;;;;;;;;;;;;;;;;;;;;;CAqB3E,YAAY,QAAqD;AAA7C,OAAA,SAAA;;;;;;;;;;;;;;;;;;;;;;CAsBpB,OACE,aACA,GAAG,MAGH;AACA,SAAO,KAAK,OAAO,QAAQ,aAAa;GACtC,GAAG,KAAK,OAAO;GACf,GAAG,KAAK;GACT,CAAQ;;;;;;;;;;;;;;;;;;;;;;;;ACvCb,IAAa,qBAAoD;CAC/D,MAAM,WAAW,GAAG,SAAkB;AACpC,SAAO,UAAU;AACjB,SAAO,KAAK,SAAS,QAAQ;AAC3B,OAAI,GAAG,KAAK;IACZ;;AAEJ,QAAO,UAAU,KAAA;AAEjB,QAAO,OAAO,EAAE;AAEhB,QAAO,SAAS,QAAwB;AACtC,SAAO,OAAO,OAAO,KAAK,QAAQ,OAAO,OAAO,IAAI;;AAEtD,QAAO,OAAO,QAAwB;AACpC,SAAO,KAAK,KAAK,IAAI;AACrB,eAAa,OAAO,MAAM,IAAI;;AAGhC,QAAO"}
package/complex.d.ts CHANGED
@@ -1,5 +1,21 @@
1
1
  import { AnyObject, Maybe, EmptyObject, Class, IsPartial } from 'yummies/types';
2
2
 
3
+ /**
4
+ * ---header-docs-section---
5
+ * # yummies/complex
6
+ *
7
+ * ## Description
8
+ *
9
+ * Callable **counter** objects with increment, decrement, and reset for UI steppers, pagination,
10
+ * and id generators. Values can be mapped on read so the public API stays typed while the internal
11
+ * tick stays numeric. This file is the `counter` slice of the broader `yummies/complex` entry point.
12
+ *
13
+ * ## Usage
14
+ *
15
+ * ```ts
16
+ * import { createCounter } from "yummies/complex";
17
+ * ```
18
+ */
3
19
  interface Counter<TValue = number> {
4
20
  (): TValue;
5
21
  counter: number;
@@ -38,6 +54,23 @@ interface CounterFn<TValue = number> extends Counter<TValue> {
38
54
  */
39
55
  declare const createCounter: <TValue = number>(processValue?: (value: number) => TValue, initial?: number) => Counter<TValue>;
40
56
 
57
+ /**
58
+ * ---header-docs-section---
59
+ * # yummies/complex
60
+ *
61
+ * ## Description
62
+ *
63
+ * **Singleton-style config** backed by either `globalThis` (keyed by symbol) or a module closure.
64
+ * Use for app-wide feature flags, bootstrapped locale, or SSR-safe defaults without prop-drilling.
65
+ * Pairs with `createGlobalPoint` for other global handles in the same `yummies/complex` package.
66
+ *
67
+ * ## Usage
68
+ *
69
+ * ```ts
70
+ * import { createGlobalConfig } from "yummies/complex";
71
+ * ```
72
+ */
73
+
41
74
  /**
42
75
  * Creates or reuses a globally accessible config object.
43
76
  *
@@ -92,6 +125,23 @@ interface GlobalDynamicConfig<TValue extends AnyObject> {
92
125
  */
93
126
  declare const createGlobalDynamicConfig: <T extends AnyObject>(processFn: (change: Maybe<Partial<T>>, current: Maybe<T>) => T, accessSymbol?: keyof any) => GlobalDynamicConfig<T>;
94
127
 
128
+ /**
129
+ * ---header-docs-section---
130
+ * # yummies/complex
131
+ *
132
+ * ## Description
133
+ *
134
+ * **Dependency-injection style factory** for classes that take a single deps object in their
135
+ * constructor. Merges predefined singletons with per-call overrides so feature modules can be
136
+ * constructed consistently in apps that avoid heavyweight DI containers.
137
+ *
138
+ * ## Usage
139
+ *
140
+ * ```ts
141
+ * import { ModulesFactory } from "yummies/complex";
142
+ * ```
143
+ */
144
+
95
145
  type ModuleLoaderConfig<TPredefinedDeps extends AnyObject = EmptyObject> = {
96
146
  factory<TInstance, TDeps extends TPredefinedDeps>(moduleClass: Class<TInstance, [TDeps]>, deps: TDeps): TInstance;
97
147
  } & (TPredefinedDeps extends EmptyObject ? {
@@ -175,6 +225,22 @@ declare class ModulesFactory<TPredefinedDeps extends AnyObject = EmptyObject> {
175
225
  create<TInstance, TDeps extends TPredefinedDeps = TPredefinedDeps>(Constructor: Class<TInstance, [TDeps]>, ...args: IsPartial<Omit<TDeps, keyof TPredefinedDeps>> extends true ? [extraDeps?: Omit<TDeps, keyof TPredefinedDeps>] : [extraDeps: Omit<TDeps, keyof TPredefinedDeps>]): TInstance;
176
226
  }
177
227
 
228
+ /**
229
+ * ---header-docs-section---
230
+ * # yummies/complex
231
+ *
232
+ * ## Description
233
+ *
234
+ * Tiny **publish–subscribe** bus: subscribers register callbacks, publishers broadcast arguments, and
235
+ * the last payload remains readable for late subscribers. Simpler than full event emitters when you
236
+ * only need in-memory fan-out inside a feature or view-model layer.
237
+ *
238
+ * ## Usage
239
+ *
240
+ * ```ts
241
+ * import { createPubSub } from "yummies/complex";
242
+ * ```
243
+ */
178
244
  type SubFn<PubArgs extends any[] = any[]> = (...args: PubArgs) => void;
179
245
  /**
180
246
  * The Publish-Subscribe pattern, which allows objects to interact with each other