patron-oop 1.39.1 → 1.41.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 (52) hide show
  1. package/.husky/pre-push +2 -0
  2. package/CHANGELOG.md +19 -0
  3. package/dist/patron.cjs +186 -96
  4. package/dist/patron.cjs.map +1 -1
  5. package/dist/patron.d.ts +21 -24
  6. package/dist/patron.js +185 -95
  7. package/dist/patron.js.map +1 -1
  8. package/dist/patron.min.js +1 -1
  9. package/dist/patron.min.mjs +1 -1
  10. package/dist/patron.min.mjs.map +1 -1
  11. package/dist/patron.mjs +185 -95
  12. package/dist/patron.mjs.map +1 -1
  13. package/eslint.config.mjs +6 -7
  14. package/package.json +7 -4
  15. package/src/Guest/Guest.ts +15 -2
  16. package/src/Guest/GuestAware.ts +26 -6
  17. package/src/Guest/GuestAwareActive.test.ts +5 -7
  18. package/src/Guest/GuestAwareActive.ts +12 -3
  19. package/src/Guest/GuestAwareMap.defered.test.ts +13 -15
  20. package/src/Guest/GuestAwareMap.fn.test.ts +6 -9
  21. package/src/Guest/GuestAwareMap.test.ts +8 -11
  22. package/src/Guest/GuestAwareMap.ts +24 -13
  23. package/src/Guest/GuestAwareRace.test.ts +8 -8
  24. package/src/Guest/GuestAwareRace.ts +12 -5
  25. package/src/Guest/GuestAwareSequence.defered.test.ts +20 -17
  26. package/src/Guest/GuestAwareSequence.test.ts +7 -10
  27. package/src/Guest/GuestAwareSequence.ts +31 -19
  28. package/src/Guest/GuestCast.test.ts +3 -3
  29. package/src/Guest/GuestCast.ts +10 -6
  30. package/src/Guest/GuestDisposable.ts +8 -1
  31. package/src/Guest/GuestObject.ts +6 -5
  32. package/src/Guest/GuestPool.test.ts +15 -2
  33. package/src/Guest/GuestSync.ts +5 -1
  34. package/src/Patron/Patron.ts +5 -1
  35. package/src/Patron/PatronOnce.sourceEmpty.test.ts +7 -4
  36. package/src/Patron/PatronOnce.test.ts +2 -2
  37. package/src/Patron/PatronOnce.ts +5 -1
  38. package/src/Patron/PatronPool.ts +6 -0
  39. package/src/Private/Private.test.ts +12 -0
  40. package/src/Private/Private.ts +20 -0
  41. package/src/Private/PrivateClass.modules.test.ts +33 -0
  42. package/src/Private/PrivateClass.test.ts +12 -0
  43. package/src/Private/PrivateClass.ts +29 -0
  44. package/src/Source/Source.ts +5 -1
  45. package/src/Source/SourceDynamic.ofSource.test.ts +4 -4
  46. package/src/Source/SourceDynamic.test.ts +2 -2
  47. package/src/Source/SourceDynamic.ts +9 -2
  48. package/src/index.ts +2 -2
  49. package/src/Factory/Factory.test.ts +0 -42
  50. package/src/Factory/Factory.ts +0 -30
  51. package/src/Factory/Module.test.ts +0 -12
  52. package/src/Factory/Module.ts +0 -12
package/dist/patron.js CHANGED
@@ -1,4 +1,10 @@
1
1
  function value(guestAware, guest) {
2
+ if (guestAware === void 0) {
3
+ throw new Error("value didnt receive guestAware argument");
4
+ }
5
+ if (guest === void 0) {
6
+ throw new Error("value didnt receive guest argument");
7
+ }
2
8
  if (typeof guestAware === "function") {
3
9
  return guestAware(guest);
4
10
  } else {
@@ -6,11 +12,17 @@ function value(guestAware, guest) {
6
12
  }
7
13
  }
8
14
  function isGuestAware(mbGuestAware) {
15
+ if (mbGuestAware === void 0) {
16
+ throw new Error("isGuestAware didnt receive mbGuestAware argument");
17
+ }
9
18
  return typeof mbGuestAware === "function" || typeof mbGuestAware?.value === "function";
10
19
  }
11
20
  class GuestAware {
12
21
  constructor(guestAware) {
13
22
  this.guestAware = guestAware;
23
+ if (guestAware === void 0) {
24
+ throw new Error("GuestAware constructor didnt receive executor function");
25
+ }
14
26
  }
15
27
  value(guest) {
16
28
  value(this.guestAware, guest);
@@ -19,6 +31,12 @@ class GuestAware {
19
31
  }
20
32
 
21
33
  function give(data, guest, options) {
34
+ if (data === void 0) {
35
+ throw new Error("give didnt receive data argument");
36
+ }
37
+ if (guest === void 0) {
38
+ throw new Error("give didnt receive guest argument");
39
+ }
22
40
  if (typeof guest === "function") {
23
41
  guest(data, options);
24
42
  } else {
@@ -26,11 +44,17 @@ function give(data, guest, options) {
26
44
  }
27
45
  }
28
46
  function isGuest(mbGuest) {
47
+ if (mbGuest === void 0) {
48
+ throw new Error("isGuest didnt receive mbGuest argument");
49
+ }
29
50
  return typeof mbGuest === "function" || typeof mbGuest?.give === "function";
30
51
  }
31
52
  class Guest {
32
53
  constructor(receiver) {
33
54
  this.receiver = receiver;
55
+ if (!receiver) {
56
+ throw new Error("reseiver function was not passed to Guest constructor");
57
+ }
34
58
  }
35
59
  give(value, options) {
36
60
  this.receiver(value, options);
@@ -38,10 +62,46 @@ class Guest {
38
62
  }
39
63
  }
40
64
 
65
+ var __defProp$6 = Object.defineProperty;
66
+ var __defNormalProp$6 = (obj, key, value) => key in obj ? __defProp$6(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
67
+ var __publicField$6 = (obj, key, value) => __defNormalProp$6(obj, key + "" , value);
68
+ class PatronOnce {
69
+ constructor(baseGuest) {
70
+ this.baseGuest = baseGuest;
71
+ __publicField$6(this, "received", false);
72
+ if (baseGuest === void 0) {
73
+ throw new Error("PatronOnce didnt receive baseGuest argument");
74
+ }
75
+ }
76
+ introduction() {
77
+ return "patron";
78
+ }
79
+ give(value, options) {
80
+ if (!this.received) {
81
+ this.received = true;
82
+ give(value, this.baseGuest, options);
83
+ }
84
+ return this;
85
+ }
86
+ disposed(value) {
87
+ if (this.received) {
88
+ return true;
89
+ }
90
+ const maybeDisposable = this.baseGuest;
91
+ return maybeDisposable.disposed ? maybeDisposable.disposed(value) : false;
92
+ }
93
+ }
94
+
41
95
  class GuestCast {
42
96
  constructor(sourceGuest, targetGuest) {
43
97
  this.sourceGuest = sourceGuest;
44
98
  this.targetGuest = targetGuest;
99
+ if (sourceGuest === void 0) {
100
+ throw new Error("GuestCast didnt receive sourceGuest argument");
101
+ }
102
+ if (targetGuest === void 0) {
103
+ throw new Error("GuestCast didnt receive targetGuest argument");
104
+ }
45
105
  }
46
106
  introduction() {
47
107
  if (typeof this.sourceGuest === "function") {
@@ -68,16 +128,22 @@ class GuestCast {
68
128
  }
69
129
  }
70
130
 
71
- var __defProp$6 = Object.defineProperty;
72
- var __defNormalProp$6 = (obj, key, value) => key in obj ? __defProp$6(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
73
- var __publicField$6 = (obj, key, value) => __defNormalProp$6(obj, typeof key !== "symbol" ? key + "" : key, value);
131
+ var __defProp$5 = Object.defineProperty;
132
+ var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
133
+ var __publicField$5 = (obj, key, value) => __defNormalProp$5(obj, typeof key !== "symbol" ? key + "" : key, value);
74
134
  const poolSets = /* @__PURE__ */ new Map();
75
135
  const removePatronFromPools = (patron) => {
136
+ if (patron === void 0) {
137
+ throw new Error("removePatronFromPools didnt receive patron argument");
138
+ }
76
139
  poolSets.forEach((pool) => {
77
140
  pool.delete(patron);
78
141
  });
79
142
  };
80
143
  const isPatronInPools = (patron) => {
144
+ if (patron === void 0) {
145
+ throw new Error("isPatronInPools didnt receive patron argument");
146
+ }
81
147
  let inPool = false;
82
148
  poolSets.forEach((pool) => {
83
149
  if (!inPool) {
@@ -89,8 +155,8 @@ const isPatronInPools = (patron) => {
89
155
  class PatronPool {
90
156
  constructor(initiator) {
91
157
  this.initiator = initiator;
92
- __publicField$6(this, "patrons");
93
- __publicField$6(this, "give");
158
+ __publicField$5(this, "patrons");
159
+ __publicField$5(this, "give");
94
160
  this.patrons = /* @__PURE__ */ new Set();
95
161
  poolSets.set(this, this.patrons);
96
162
  let lastMicrotask = null;
@@ -153,13 +219,16 @@ class PatronPool {
153
219
  }
154
220
  }
155
221
 
156
- var __defProp$5 = Object.defineProperty;
157
- var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
158
- var __publicField$5 = (obj, key, value) => __defNormalProp$5(obj, key + "" , value);
222
+ var __defProp$4 = Object.defineProperty;
223
+ var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
224
+ var __publicField$4 = (obj, key, value) => __defNormalProp$4(obj, key + "" , value);
159
225
  class Source {
160
226
  constructor(sourceDocument) {
161
227
  this.sourceDocument = sourceDocument;
162
- __publicField$5(this, "thePool", new PatronPool(this));
228
+ __publicField$4(this, "thePool", new PatronPool(this));
229
+ if (sourceDocument === void 0) {
230
+ throw new Error("Source didnt receive sourceDocument argument");
231
+ }
163
232
  }
164
233
  pool() {
165
234
  return this.thePool;
@@ -179,9 +248,38 @@ class Source {
179
248
  }
180
249
  }
181
250
 
251
+ var __defProp$3 = Object.defineProperty;
252
+ var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
253
+ var __publicField$3 = (obj, key, value) => __defNormalProp$3(obj, key + "" , value);
254
+ class SourceEmpty {
255
+ constructor() {
256
+ __publicField$3(this, "baseSource", new Source(null));
257
+ }
258
+ value(guest) {
259
+ this.baseSource.value(
260
+ new GuestCast(guest, (value, options) => {
261
+ if (value !== null) {
262
+ give(value, guest, options);
263
+ }
264
+ })
265
+ );
266
+ return this;
267
+ }
268
+ give(value) {
269
+ this.baseSource.give(value);
270
+ return this;
271
+ }
272
+ pool() {
273
+ return this.baseSource.pool();
274
+ }
275
+ }
276
+
182
277
  class GuestObject {
183
278
  constructor(baseGuest) {
184
279
  this.baseGuest = baseGuest;
280
+ if (baseGuest === void 0) {
281
+ throw new Error("GuestObject didnt receive baseGuest argument");
282
+ }
185
283
  }
186
284
  give(value, options) {
187
285
  let guest = this.baseGuest;
@@ -203,13 +301,13 @@ class GuestObject {
203
301
  }
204
302
  }
205
303
 
206
- var __defProp$4 = Object.defineProperty;
207
- var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
208
- var __publicField$4 = (obj, key, value) => __defNormalProp$4(obj, typeof key !== "symbol" ? key + "" : key, value);
304
+ var __defProp$2 = Object.defineProperty;
305
+ var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
306
+ var __publicField$2 = (obj, key, value) => __defNormalProp$2(obj, typeof key !== "symbol" ? key + "" : key, value);
209
307
  class GuestPool {
210
308
  constructor(initiator) {
211
- __publicField$4(this, "guests", /* @__PURE__ */ new Set());
212
- __publicField$4(this, "patronPool");
309
+ __publicField$2(this, "guests", /* @__PURE__ */ new Set());
310
+ __publicField$2(this, "patronPool");
213
311
  this.patronPool = new PatronPool(initiator);
214
312
  }
215
313
  give(value, options) {
@@ -245,15 +343,15 @@ class GuestPool {
245
343
  }
246
344
  }
247
345
 
248
- var __defProp$3 = Object.defineProperty;
249
- var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
250
- var __publicField$3 = (obj, key, value) => __defNormalProp$3(obj, typeof key !== "symbol" ? key + "" : key, value);
346
+ var __defProp$1 = Object.defineProperty;
347
+ var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
348
+ var __publicField$1 = (obj, key, value) => __defNormalProp$1(obj, typeof key !== "symbol" ? key + "" : key, value);
251
349
  class GuestAwareAll {
252
350
  constructor() {
253
- __publicField$3(this, "theAll");
254
- __publicField$3(this, "keysKnown", /* @__PURE__ */ new Set());
255
- __publicField$3(this, "keysFilled", /* @__PURE__ */ new Set());
256
- __publicField$3(this, "filledAllPool", new GuestPool(this));
351
+ __publicField$1(this, "theAll");
352
+ __publicField$1(this, "keysKnown", /* @__PURE__ */ new Set());
353
+ __publicField$1(this, "keysFilled", /* @__PURE__ */ new Set());
354
+ __publicField$1(this, "filledAllPool", new GuestPool(this));
257
355
  this.theAll = new Source({});
258
356
  }
259
357
  valueArray(guest) {
@@ -311,70 +409,21 @@ class GuestAwareAll {
311
409
  }
312
410
  }
313
411
 
314
- var __defProp$2 = Object.defineProperty;
315
- var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
316
- var __publicField$2 = (obj, key, value) => __defNormalProp$2(obj, key + "" , value);
317
- class SourceEmpty {
318
- constructor() {
319
- __publicField$2(this, "baseSource", new Source(null));
320
- }
321
- value(guest) {
322
- this.baseSource.value(
323
- new GuestCast(guest, (value, options) => {
324
- if (value !== null) {
325
- give(value, guest, options);
326
- }
327
- })
328
- );
329
- return this;
330
- }
331
- give(value) {
332
- this.baseSource.give(value);
333
- return this;
334
- }
335
- pool() {
336
- return this.baseSource.pool();
337
- }
338
- }
339
-
340
- var __defProp$1 = Object.defineProperty;
341
- var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
342
- var __publicField$1 = (obj, key, value) => __defNormalProp$1(obj, key + "" , value);
343
- class PatronOnce {
344
- constructor(baseGuest) {
345
- this.baseGuest = baseGuest;
346
- __publicField$1(this, "received", false);
347
- }
348
- introduction() {
349
- return "patron";
350
- }
351
- give(value, options) {
352
- if (!this.received) {
353
- this.received = true;
354
- give(value, this.baseGuest, options);
355
- }
356
- return this;
357
- }
358
- disposed(value) {
359
- if (this.received) {
360
- return true;
361
- }
362
- const maybeDisposable = this.baseGuest;
363
- return maybeDisposable.disposed ? maybeDisposable.disposed(value) : false;
364
- }
365
- }
366
-
367
412
  class GuestAwareSequence {
368
- constructor(baseSource, targetSourceFactory) {
413
+ constructor(baseSource, targetSource) {
369
414
  this.baseSource = baseSource;
370
- this.targetSourceFactory = targetSourceFactory;
415
+ this.targetSource = targetSource;
416
+ if (baseSource === void 0) {
417
+ throw new Error("GuestAwareSequence didnt receive baseSource argument");
418
+ }
419
+ if (targetSource === void 0) {
420
+ throw new Error("GuestAwareSequence didnt receive targetSource argument");
421
+ }
371
422
  }
372
423
  value(guest) {
373
424
  const all = new GuestAwareAll();
374
425
  const sequenceSource = new SourceEmpty();
375
- const targetSource = this.targetSourceFactory.create(
376
- sequenceSource
377
- );
426
+ const targetSource = this.targetSource.get(sequenceSource);
378
427
  value(
379
428
  this.baseSource,
380
429
  new GuestCast(guest, (theValue) => {
@@ -391,11 +440,14 @@ class GuestAwareSequence {
391
440
  sequenceSource.give(null);
392
441
  const nextValue = theValue[index];
393
442
  if (isGuestAware(nextValue)) {
394
- value(nextValue, new PatronOnce((theNextValue) => {
395
- sequenceSource.give(theNextValue);
396
- value(targetSource, all.guestKey(index.toString()));
397
- nextItemHandle();
398
- }));
443
+ value(
444
+ nextValue,
445
+ new PatronOnce((theNextValue) => {
446
+ sequenceSource.give(theNextValue);
447
+ value(targetSource, all.guestKey(index.toString()));
448
+ nextItemHandle();
449
+ })
450
+ );
399
451
  } else {
400
452
  sequenceSource.give(nextValue);
401
453
  value(targetSource, all.guestKey(index.toString()));
@@ -414,9 +466,15 @@ class GuestAwareSequence {
414
466
  }
415
467
 
416
468
  class GuestAwareMap {
417
- constructor(baseSource, targetSourceFactory) {
469
+ constructor(baseSource, targetSource) {
418
470
  this.baseSource = baseSource;
419
- this.targetSourceFactory = targetSourceFactory;
471
+ this.targetSource = targetSource;
472
+ if (baseSource === void 0) {
473
+ throw new Error("GuestAwareMap didnt receive baseSource argument");
474
+ }
475
+ if (targetSource === void 0) {
476
+ throw new Error("GuestAwareMap didnt receive targetSource argument");
477
+ }
420
478
  }
421
479
  value(guest) {
422
480
  const all = new GuestAwareAll();
@@ -427,7 +485,7 @@ class GuestAwareMap {
427
485
  const valueSource = isGuestAware(val) ? val : new GuestAware((innerGuest) => {
428
486
  give(val, innerGuest);
429
487
  });
430
- const targetSource = this.targetSourceFactory.create(valueSource);
488
+ const targetSource = this.targetSource.get(valueSource);
431
489
  value(targetSource, all.guestKey(index.toString()));
432
490
  });
433
491
  })
@@ -440,6 +498,9 @@ class GuestAwareMap {
440
498
  class GuestAwareRace {
441
499
  constructor(guestAwares) {
442
500
  this.guestAwares = guestAwares;
501
+ if (guestAwares === void 0) {
502
+ throw new Error("GuestAwareRace didnt receive guestAwares argument");
503
+ }
443
504
  }
444
505
  value(guest) {
445
506
  let connectedWithGuestAware = null;
@@ -465,6 +526,11 @@ class GuestAwareActive {
465
526
  constructor(configExecutor) {
466
527
  this.configExecutor = configExecutor;
467
528
  __publicField(this, "source", new SourceEmpty());
529
+ if (configExecutor === void 0) {
530
+ throw new Error(
531
+ "GuestAwareActive constructor didnt receive executor function"
532
+ );
533
+ }
468
534
  }
469
535
  do(config) {
470
536
  this.configExecutor(config, this.source);
@@ -479,6 +545,9 @@ class GuestAwareActive {
479
545
  class GuestSync {
480
546
  constructor(theValue) {
481
547
  this.theValue = theValue;
548
+ if (theValue === void 0) {
549
+ throw new Error("GuestSync didnt receive theValue argument");
550
+ }
482
551
  }
483
552
  give(value) {
484
553
  this.theValue = value;
@@ -493,6 +562,12 @@ class GuestDisposable {
493
562
  constructor(guest, disposeCheck) {
494
563
  this.guest = guest;
495
564
  this.disposeCheck = disposeCheck;
565
+ if (guest === void 0) {
566
+ throw new Error("GuestDisposable didnt receive guest argument");
567
+ }
568
+ if (disposeCheck === void 0) {
569
+ throw new Error("GuestDisposable didnt receive disposeCheck argument");
570
+ }
496
571
  }
497
572
  disposed(value) {
498
573
  return this.disposeCheck(value);
@@ -506,6 +581,9 @@ class GuestDisposable {
506
581
  class Patron {
507
582
  constructor(willBePatron) {
508
583
  this.willBePatron = willBePatron;
584
+ if (willBePatron === void 0) {
585
+ throw new Error("Patron didnt receive willBePatron argument");
586
+ }
509
587
  }
510
588
  introduction() {
511
589
  return "patron";
@@ -524,6 +602,12 @@ class SourceDynamic {
524
602
  constructor(baseGuest, baseGuestAware) {
525
603
  this.baseGuest = baseGuest;
526
604
  this.baseGuestAware = baseGuestAware;
605
+ if (baseGuest === void 0) {
606
+ throw new Error("SourceDynamic didnt receive baseGuest argument");
607
+ }
608
+ if (baseGuestAware === void 0) {
609
+ throw new Error("SourceDynamic didnt receive baseGuestAware argument");
610
+ }
527
611
  }
528
612
  value(guest) {
529
613
  value(this.baseGuestAware, guest);
@@ -538,27 +622,33 @@ class SourceDynamic {
538
622
  }
539
623
  }
540
624
 
541
- class Factory {
542
- constructor(constructorFn, factories = {}) {
625
+ class PrivateClass {
626
+ constructor(constructorFn, modules = {}) {
543
627
  this.constructorFn = constructorFn;
544
- this.factories = factories;
628
+ this.modules = modules;
629
+ if (constructorFn === void 0) {
630
+ throw new Error("PrivateClass didnt receive constructorFn argument");
631
+ }
545
632
  }
546
- create(...args) {
633
+ get(...args) {
547
634
  return new this.constructorFn(
548
635
  ...args,
549
- this.factories
636
+ this.modules
550
637
  );
551
638
  }
552
639
  }
553
640
 
554
- class Module {
641
+ class Private {
555
642
  constructor(buildingFn) {
556
643
  this.buildingFn = buildingFn;
644
+ if (buildingFn === void 0) {
645
+ throw new Error("Private didnt receive buildingFn argument");
646
+ }
557
647
  }
558
- create(...args) {
648
+ get(...args) {
559
649
  return this.buildingFn(...args);
560
650
  }
561
651
  }
562
652
 
563
- export { Factory, Guest, GuestAware, GuestAwareActive, GuestAwareAll, GuestAwareMap, GuestAwareRace, GuestAwareSequence, GuestCast, GuestDisposable, GuestObject, GuestPool, GuestSync, Module, Patron, PatronOnce, PatronPool, Source, SourceDynamic, SourceEmpty, give, isGuest, isGuestAware, isPatronInPools, removePatronFromPools, value };
653
+ export { Guest, GuestAware, GuestAwareActive, GuestAwareAll, GuestAwareMap, GuestAwareRace, GuestAwareSequence, GuestCast, GuestDisposable, GuestObject, GuestPool, GuestSync, Patron, PatronOnce, PatronPool, Private, PrivateClass, Source, SourceDynamic, SourceEmpty, give, isGuest, isGuestAware, isPatronInPools, removePatronFromPools, value };
564
654
  //# sourceMappingURL=patron.js.map