patron-oop 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/LICENSE.md +7 -0
  3. package/README.md +9 -0
  4. package/commitizen.cjs +50 -0
  5. package/dist/patron.d.ts +173 -0
  6. package/dist/patron.js +363 -0
  7. package/dist/patron.js.map +1 -0
  8. package/dist/patron.mjs +346 -0
  9. package/dist/patron.mjs.map +1 -0
  10. package/eslint.config.mjs +36 -0
  11. package/package.json +48 -0
  12. package/rollup.config.js +35 -0
  13. package/src/Cache.test.ts +20 -0
  14. package/src/Cache.ts +31 -0
  15. package/src/CacheType.ts +4 -0
  16. package/src/Chain.test.ts +72 -0
  17. package/src/Chain.ts +79 -0
  18. package/src/ChainType.ts +7 -0
  19. package/src/Factory.test.ts +16 -0
  20. package/src/Factory.ts +21 -0
  21. package/src/FactoryDynamic.ts +11 -0
  22. package/src/FactoryType.ts +3 -0
  23. package/src/FactoryWithFactories.ts +25 -0
  24. package/src/Guest.test.ts +13 -0
  25. package/src/Guest.ts +11 -0
  26. package/src/GuestAware.ts +11 -0
  27. package/src/GuestAwareType.ts +5 -0
  28. package/src/GuestCast.ts +20 -0
  29. package/src/GuestExecutorType.ts +3 -0
  30. package/src/GuestInTheMiddle.test.ts +71 -0
  31. package/src/GuestInTheMiddle.ts +20 -0
  32. package/src/GuestPool.test.ts +41 -0
  33. package/src/GuestPool.ts +46 -0
  34. package/src/GuestSync.test.ts +11 -0
  35. package/src/GuestSync.ts +14 -0
  36. package/src/GuestType.ts +10 -0
  37. package/src/GuestValueType.ts +5 -0
  38. package/src/Patron.test.ts +20 -0
  39. package/src/Patron.ts +17 -0
  40. package/src/PatronOnce.test.ts +18 -0
  41. package/src/PatronOnce.ts +30 -0
  42. package/src/PatronPool.test.ts +26 -0
  43. package/src/PatronPool.ts +76 -0
  44. package/src/PoolType.ts +7 -0
  45. package/src/Source.test.ts +13 -0
  46. package/src/Source.ts +20 -0
  47. package/src/SourceType.ts +4 -0
  48. package/src/index.ts +16 -0
  49. package/tsconfig.json +26 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,11 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
+
5
+ ## 1.1.0 (2024-10-12)
6
+
7
+
8
+ ### Features
9
+
10
+ * **main:** добавил лицензию ([aa13568](https://github.com/kosukhin/patron/commit/aa13568c5c36735b800ed0270214388e4fa67324))
11
+ * **main:** Начальный комит ([1205f63](https://github.com/kosukhin/patron/commit/1205f6330f52a451df2a702043b87d2b9b84e0c3))
package/LICENSE.md ADDED
@@ -0,0 +1,7 @@
1
+ Copyright (c) 2024 Eugene Kosukhin and others
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,9 @@
1
+ # Patron JS
2
+
3
+ [Документация](https://kosukhin.github.io/patron.site/)
4
+
5
+ Patron JS - это библиотека для ООП программирования на JS.
6
+ Основная идея библиотеки заключается в том, чтобы максимально изолировать внутреннюю логику объектов от других объектов.
7
+
8
+ Patron - это сущность, которая является посетителем какого-либо объекта и приходит к объекту за результатом вычисления.
9
+ Guest - это почти такая же сущность как и Patron, разница только в том что Patron нужно постоянно уведомлять об изменениях а Guest не нужно.
package/commitizen.cjs ADDED
@@ -0,0 +1,50 @@
1
+ const { execSync } = require("child_process");
2
+
3
+ function getGitBranch() {
4
+ const res = execSync("git rev-parse --abbrev-ref HEAD", { encoding: "utf8" });
5
+ return res.trim();
6
+ }
7
+
8
+ module.exports = {
9
+ types: [
10
+ {
11
+ value: "feat",
12
+ name: "feat: Добавление нового функционала",
13
+ },
14
+ {
15
+ value: "refactor",
16
+ name: "refactor: Правки кода без исправления ошибок или добавления новых функций",
17
+ },
18
+ {
19
+ value: "fix",
20
+ name: "fix: Исправление ошибок",
21
+ },
22
+ {
23
+ value: "build",
24
+ name: "build: Сборка проекта или изменения внешних зависимостей",
25
+ },
26
+ {
27
+ value: "docs",
28
+ name: "docs: Обновление документации",
29
+ },
30
+ {
31
+ value: "docs",
32
+ name: "docs: Правки по документации проекта или отдельных частей проекта",
33
+ },
34
+ {
35
+ value: "test",
36
+ name: "test: Добавление тестов",
37
+ },
38
+ ],
39
+ scopes: [
40
+ {
41
+ name: getGitBranch(),
42
+ },
43
+ ],
44
+
45
+ allowCustomScopes: true,
46
+
47
+ allowBreakingChanges: false,
48
+
49
+ subjectLimit: 72,
50
+ };
@@ -0,0 +1,173 @@
1
+ type GuestIntroduction = "guest" | "patron";
2
+ interface ReceiveOptions {
3
+ data?: unknown;
4
+ }
5
+ interface GuestType<T = unknown> {
6
+ receive(value: T, options?: ReceiveOptions): this;
7
+ introduction?(): GuestIntroduction;
8
+ }
9
+
10
+ interface GuestAwareType<T = unknown> {
11
+ receiving(guest: GuestType<T>): unknown;
12
+ }
13
+
14
+ type CacheType<T = unknown> = GuestType<T> & GuestAwareType<T>;
15
+
16
+ declare class Cache<T> implements CacheType<T> {
17
+ private defaultValue;
18
+ private theCache;
19
+ private pool;
20
+ constructor(initiator: unknown, defaultValue?: T | null, theCache?: T | null);
21
+ receive(value: T, options?: ReceiveOptions): this;
22
+ receiving(guest: GuestType<T>): this;
23
+ }
24
+
25
+ interface ChainType<T = unknown> {
26
+ result(guest: GuestType<T>): this;
27
+ resultArray(guest: GuestType<T>): this;
28
+ receiveKey<R>(key: string): GuestType<R>;
29
+ }
30
+
31
+ declare class Chain<T> implements ChainType<T> {
32
+ private theChain;
33
+ private keysKnown;
34
+ private keysFilled;
35
+ private filledChainPool;
36
+ constructor();
37
+ resultArray(guest: GuestType<T>): this;
38
+ result(guest: GuestType<T>): this;
39
+ receiveKey<R>(key: string): GuestType<R>;
40
+ private isChainFilled;
41
+ }
42
+
43
+ interface FactoryType<T> {
44
+ create<R extends unknown[], CT = null>(...args: R): CT extends null ? T : CT;
45
+ }
46
+
47
+ interface Prototyped$1<T> {
48
+ prototype: T;
49
+ }
50
+ declare class Factory<T> implements FactoryType<T> {
51
+ private constructorFn;
52
+ constructor(constructorFn: Prototyped$1<T>);
53
+ create<R extends unknown[], CT = null>(...args: R): CT extends null ? T : CT;
54
+ }
55
+
56
+ declare class FactoryDynamic<T> implements FactoryType<T> {
57
+ private creationFn;
58
+ constructor(creationFn: (...args: unknown[]) => T);
59
+ create<R extends unknown[], CT = null>(...args: R): CT extends null ? T : CT;
60
+ }
61
+
62
+ interface Prototyped<T> {
63
+ prototype: T;
64
+ }
65
+ declare class FactoryWithFactories<T> implements FactoryType<T> {
66
+ private constructorFn;
67
+ private factories;
68
+ constructor(constructorFn: Prototyped<T>, factories?: Record<string, unknown>);
69
+ create<R extends unknown[], CT = null>(...args: R): CT extends null ? T : CT;
70
+ }
71
+
72
+ type GuestExecutorType<T> = (value: T, options?: ReceiveOptions) => void;
73
+
74
+ declare class Guest<T> implements GuestType<T> {
75
+ private receiver;
76
+ constructor(receiver: GuestExecutorType<T>);
77
+ receive(value: T, options?: ReceiveOptions): this;
78
+ }
79
+
80
+ declare class GuestAware<T = unknown> implements GuestAwareType<T> {
81
+ private guestReceiver;
82
+ constructor(guestReceiver: (guest: GuestType<T>) => void);
83
+ receiving(guest: GuestType<T>): GuestType<T>;
84
+ }
85
+
86
+ declare class GuestCast<T> implements GuestType<T> {
87
+ private sourceGuest;
88
+ private targetGuest;
89
+ constructor(sourceGuest: GuestType<unknown>, targetGuest: GuestType<T>);
90
+ introduction(): "guest" | "patron";
91
+ receive(value: T, options?: ReceiveOptions): this;
92
+ }
93
+
94
+ declare class GuestInTheMiddle<T> implements GuestType<T> {
95
+ private baseGuest;
96
+ private middleFn;
97
+ constructor(baseGuest: GuestType<unknown>, middleFn: (value: T, options?: ReceiveOptions) => void);
98
+ introduction(): "guest" | "patron";
99
+ receive(value: T, options?: ReceiveOptions): this;
100
+ }
101
+
102
+ interface PoolType<T = unknown> extends GuestType<T> {
103
+ add(guest: GuestType<T>): this;
104
+ distribute(receiving: T, possiblePatron: GuestType<T>): this;
105
+ remove(patron: GuestType<T>): this;
106
+ }
107
+
108
+ declare class GuestPool<T> implements GuestType<T>, PoolType<T> {
109
+ private guests;
110
+ private patronPool;
111
+ constructor(initiator: unknown);
112
+ receive(value: T, options?: ReceiveOptions): this;
113
+ add(guest: GuestType<T>): this;
114
+ remove(patron: GuestType<T>): this;
115
+ distribute(receiving: T, possiblePatron: GuestType<T>): this;
116
+ private deliverToGuests;
117
+ }
118
+
119
+ interface GuestValueType<T = unknown> extends GuestType<T> {
120
+ value(): T;
121
+ }
122
+
123
+ declare class GuestSync<T> implements GuestValueType<T> {
124
+ private theValue;
125
+ constructor(theValue: T);
126
+ receive(value: T): this;
127
+ value(): T;
128
+ }
129
+
130
+ /**
131
+ * Патрон - это постоянный посетитель
132
+ */
133
+ declare class Patron<T> implements GuestType<T> {
134
+ private willBePatron;
135
+ constructor(willBePatron: GuestType<T>);
136
+ introduction(): "patron";
137
+ receive(value: T, options?: ReceiveOptions): this;
138
+ }
139
+
140
+ declare class PatronOnce<T> implements GuestType<T> {
141
+ private baseGuest;
142
+ private received;
143
+ constructor(baseGuest: GuestType<T>);
144
+ introduction(): "patron";
145
+ receive(value: T, options?: ReceiveOptions): this;
146
+ }
147
+
148
+ /**
149
+ * Удалить патрон из всех пулов
150
+ */
151
+ declare const removePatronFromPools: (patron: GuestType) => void;
152
+ declare class PatronPool<T> implements PoolType<T> {
153
+ private initiator;
154
+ private patrons;
155
+ receive: (value: T, options?: ReceiveOptions) => this;
156
+ constructor(initiator: unknown);
157
+ add(shouldBePatron: GuestType<T>): this;
158
+ remove(patron: GuestType<T>): this;
159
+ distribute(receiving: T, possiblePatron: GuestType<T>): this;
160
+ private sendValueToGuest;
161
+ }
162
+
163
+ type SourceType<T = unknown> = GuestAwareType<T> & GuestType<T>;
164
+
165
+ declare class Source<T> implements SourceType<T> {
166
+ private sourceDocument;
167
+ private pool;
168
+ constructor(sourceDocument: T);
169
+ receive(value: T): this;
170
+ receiving(guest: GuestType<T>): this;
171
+ }
172
+
173
+ export { Cache, Chain, Factory, FactoryDynamic, type FactoryType, FactoryWithFactories, Guest, GuestAware, GuestCast, GuestInTheMiddle, GuestPool, GuestSync, Patron, PatronOnce, PatronPool, Source, removePatronFromPools };
package/dist/patron.js ADDED
@@ -0,0 +1,363 @@
1
+ 'use strict';
2
+
3
+ var __defProp$5 = Object.defineProperty;
4
+ var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
5
+ var __publicField$5 = (obj, key, value) => __defNormalProp$5(obj, typeof key !== "symbol" ? key + "" : key, value);
6
+ const poolSets = /* @__PURE__ */ new Map();
7
+ const removePatronFromPools = (patron) => {
8
+ poolSets.forEach((pool) => {
9
+ pool.delete(patron);
10
+ });
11
+ };
12
+ class PatronPool {
13
+ constructor(initiator) {
14
+ this.initiator = initiator;
15
+ __publicField$5(this, "patrons", /* @__PURE__ */ new Set());
16
+ __publicField$5(this, "receive");
17
+ poolSets.set(this, this.patrons);
18
+ let lastMicrotask = null;
19
+ const doReceive = (value, options) => {
20
+ this.patrons.forEach((target) => {
21
+ this.sendValueToGuest(value, target, options);
22
+ });
23
+ };
24
+ this.receive = (value, options) => {
25
+ const currentMicroTask = () => {
26
+ if (currentMicroTask === lastMicrotask) {
27
+ doReceive(value, options);
28
+ }
29
+ };
30
+ lastMicrotask = currentMicroTask;
31
+ queueMicrotask(currentMicroTask);
32
+ return this;
33
+ };
34
+ }
35
+ add(shouldBePatron) {
36
+ if (shouldBePatron.introduction && shouldBePatron.introduction() === "patron") {
37
+ this.patrons.add(shouldBePatron);
38
+ }
39
+ return this;
40
+ }
41
+ remove(patron) {
42
+ this.patrons.delete(patron);
43
+ return this;
44
+ }
45
+ distribute(receiving, possiblePatron) {
46
+ this.add(possiblePatron);
47
+ this.sendValueToGuest(receiving, possiblePatron, {});
48
+ return this;
49
+ }
50
+ sendValueToGuest(value, guest, options) {
51
+ guest.receive(value, {
52
+ ...options,
53
+ data: {
54
+ ...options?.data ?? {},
55
+ initiator: this.initiator,
56
+ pool: this
57
+ }
58
+ });
59
+ }
60
+ }
61
+
62
+ var __defProp$4 = Object.defineProperty;
63
+ var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
64
+ var __publicField$4 = (obj, key, value) => __defNormalProp$4(obj, key + "" , value);
65
+ class Cache {
66
+ constructor(initiator, defaultValue = null, theCache = null) {
67
+ this.defaultValue = defaultValue;
68
+ this.theCache = theCache;
69
+ __publicField$4(this, "pool");
70
+ this.pool = new PatronPool(initiator);
71
+ }
72
+ receive(value, options) {
73
+ this.theCache = value;
74
+ this.pool.receive(value, options);
75
+ return this;
76
+ }
77
+ receiving(guest) {
78
+ if (this.theCache !== null) {
79
+ guest.receive(this.theCache);
80
+ } else if (this.defaultValue !== null) {
81
+ guest.receive(this.defaultValue);
82
+ }
83
+ this.pool.add(guest);
84
+ return this;
85
+ }
86
+ }
87
+
88
+ class Guest {
89
+ constructor(receiver) {
90
+ this.receiver = receiver;
91
+ }
92
+ receive(value, options) {
93
+ this.receiver(value, options);
94
+ return this;
95
+ }
96
+ }
97
+
98
+ var __defProp$3 = Object.defineProperty;
99
+ var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
100
+ var __publicField$3 = (obj, key, value) => __defNormalProp$3(obj, typeof key !== "symbol" ? key + "" : key, value);
101
+ class GuestPool {
102
+ constructor(initiator) {
103
+ __publicField$3(this, "guests", /* @__PURE__ */ new Set());
104
+ __publicField$3(this, "patronPool");
105
+ this.patronPool = new PatronPool(initiator);
106
+ }
107
+ receive(value, options) {
108
+ this.deliverToGuests(value, options);
109
+ this.patronPool.receive(value, options);
110
+ return this;
111
+ }
112
+ add(guest) {
113
+ if (!guest.introduction || guest.introduction() === "guest") {
114
+ this.guests.add(guest);
115
+ }
116
+ this.patronPool.add(guest);
117
+ return this;
118
+ }
119
+ remove(patron) {
120
+ this.guests.delete(patron);
121
+ this.patronPool.remove(patron);
122
+ return this;
123
+ }
124
+ distribute(receiving, possiblePatron) {
125
+ this.add(possiblePatron);
126
+ this.receive(receiving);
127
+ return this;
128
+ }
129
+ deliverToGuests(value, options) {
130
+ this.guests.forEach((target) => {
131
+ target.receive(value, options);
132
+ });
133
+ this.guests.clear();
134
+ }
135
+ }
136
+
137
+ class GuestInTheMiddle {
138
+ constructor(baseGuest, middleFn) {
139
+ this.baseGuest = baseGuest;
140
+ this.middleFn = middleFn;
141
+ }
142
+ introduction() {
143
+ if (!this.baseGuest.introduction) {
144
+ return "guest";
145
+ }
146
+ return this.baseGuest.introduction();
147
+ }
148
+ receive(value, options) {
149
+ this.middleFn(value, options);
150
+ return this;
151
+ }
152
+ }
153
+
154
+ var __defProp$2 = Object.defineProperty;
155
+ var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
156
+ var __publicField$2 = (obj, key, value) => __defNormalProp$2(obj, typeof key !== "symbol" ? key + "" : key, value);
157
+ class Chain {
158
+ constructor() {
159
+ __publicField$2(this, "theChain");
160
+ __publicField$2(this, "keysKnown", /* @__PURE__ */ new Set());
161
+ __publicField$2(this, "keysFilled", /* @__PURE__ */ new Set());
162
+ __publicField$2(this, "filledChainPool", new GuestPool(this));
163
+ this.theChain = new Cache(this, {});
164
+ }
165
+ resultArray(guest) {
166
+ this.filledChainPool.add(
167
+ new GuestInTheMiddle(
168
+ guest,
169
+ (value) => Object.values(value)
170
+ )
171
+ );
172
+ if (this.isChainFilled()) {
173
+ this.theChain.receiving(
174
+ new Guest((chain) => {
175
+ this.filledChainPool.receive(Object.values(chain));
176
+ })
177
+ );
178
+ }
179
+ return this;
180
+ }
181
+ result(guest) {
182
+ if (this.isChainFilled()) {
183
+ this.filledChainPool.add(guest);
184
+ this.theChain.receiving(
185
+ new Guest((chain) => {
186
+ this.filledChainPool.receive(chain);
187
+ })
188
+ );
189
+ } else {
190
+ this.filledChainPool.add(guest);
191
+ }
192
+ return this;
193
+ }
194
+ receiveKey(key) {
195
+ this.keysKnown.add(key);
196
+ return new Guest((value) => {
197
+ queueMicrotask(() => {
198
+ this.theChain.receiving(
199
+ new Guest((chain) => {
200
+ this.keysFilled.add(key);
201
+ const lastChain = {
202
+ ...chain,
203
+ [key]: value
204
+ };
205
+ this.theChain.receive(lastChain);
206
+ if (this.isChainFilled()) {
207
+ this.filledChainPool.receive(lastChain);
208
+ }
209
+ })
210
+ );
211
+ });
212
+ });
213
+ }
214
+ isChainFilled() {
215
+ return this.keysFilled.size > 0 && this.keysFilled.size === this.keysKnown.size;
216
+ }
217
+ }
218
+
219
+ class Factory {
220
+ constructor(constructorFn) {
221
+ this.constructorFn = constructorFn;
222
+ }
223
+ create(...args) {
224
+ return new this.constructorFn(
225
+ ...args
226
+ );
227
+ }
228
+ }
229
+
230
+ class FactoryDynamic {
231
+ constructor(creationFn) {
232
+ this.creationFn = creationFn;
233
+ }
234
+ create(...args) {
235
+ return this.creationFn(...args);
236
+ }
237
+ }
238
+
239
+ class FactoryWithFactories {
240
+ constructor(constructorFn, factories = {}) {
241
+ this.constructorFn = constructorFn;
242
+ this.factories = factories;
243
+ }
244
+ create(...args) {
245
+ return new this.constructorFn(
246
+ ...args,
247
+ this.factories
248
+ );
249
+ }
250
+ }
251
+
252
+ class GuestAware {
253
+ constructor(guestReceiver) {
254
+ this.guestReceiver = guestReceiver;
255
+ }
256
+ receiving(guest) {
257
+ this.guestReceiver(guest);
258
+ return guest;
259
+ }
260
+ }
261
+
262
+ class GuestCast {
263
+ constructor(sourceGuest, targetGuest) {
264
+ this.sourceGuest = sourceGuest;
265
+ this.targetGuest = targetGuest;
266
+ }
267
+ introduction() {
268
+ if (!this.sourceGuest.introduction) {
269
+ return "guest";
270
+ }
271
+ return this.sourceGuest.introduction();
272
+ }
273
+ receive(value, options) {
274
+ this.targetGuest.receive(value, options);
275
+ return this;
276
+ }
277
+ }
278
+
279
+ class GuestSync {
280
+ constructor(theValue) {
281
+ this.theValue = theValue;
282
+ }
283
+ receive(value) {
284
+ this.theValue = value;
285
+ return this;
286
+ }
287
+ value() {
288
+ return this.theValue;
289
+ }
290
+ }
291
+
292
+ class Patron {
293
+ constructor(willBePatron) {
294
+ this.willBePatron = willBePatron;
295
+ }
296
+ introduction() {
297
+ return "patron";
298
+ }
299
+ receive(value, options) {
300
+ this.willBePatron.receive(value, options);
301
+ return this;
302
+ }
303
+ }
304
+
305
+ var __defProp$1 = Object.defineProperty;
306
+ var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
307
+ var __publicField$1 = (obj, key, value) => __defNormalProp$1(obj, key + "" , value);
308
+ class PatronOnce {
309
+ constructor(baseGuest) {
310
+ this.baseGuest = baseGuest;
311
+ __publicField$1(this, "received", false);
312
+ }
313
+ introduction() {
314
+ return "patron";
315
+ }
316
+ receive(value, options) {
317
+ if (!this.received) {
318
+ this.baseGuest.receive(value, options);
319
+ }
320
+ const data = options?.data;
321
+ if (data?.pool) {
322
+ data.pool.remove(this);
323
+ }
324
+ return this;
325
+ }
326
+ }
327
+
328
+ var __defProp = Object.defineProperty;
329
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
330
+ var __publicField = (obj, key, value) => __defNormalProp(obj, key + "" , value);
331
+ class Source {
332
+ constructor(sourceDocument) {
333
+ this.sourceDocument = sourceDocument;
334
+ __publicField(this, "pool", new PatronPool(this));
335
+ }
336
+ receive(value) {
337
+ this.sourceDocument = value;
338
+ this.pool.receive(this.sourceDocument);
339
+ return this;
340
+ }
341
+ receiving(guest) {
342
+ this.pool.distribute(this.sourceDocument, guest);
343
+ return this;
344
+ }
345
+ }
346
+
347
+ exports.Cache = Cache;
348
+ exports.Chain = Chain;
349
+ exports.Factory = Factory;
350
+ exports.FactoryDynamic = FactoryDynamic;
351
+ exports.FactoryWithFactories = FactoryWithFactories;
352
+ exports.Guest = Guest;
353
+ exports.GuestAware = GuestAware;
354
+ exports.GuestCast = GuestCast;
355
+ exports.GuestInTheMiddle = GuestInTheMiddle;
356
+ exports.GuestPool = GuestPool;
357
+ exports.GuestSync = GuestSync;
358
+ exports.Patron = Patron;
359
+ exports.PatronOnce = PatronOnce;
360
+ exports.PatronPool = PatronPool;
361
+ exports.Source = Source;
362
+ exports.removePatronFromPools = removePatronFromPools;
363
+ //# sourceMappingURL=patron.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"patron.js","sources":["../src/PatronPool.ts","../src/Cache.ts","../src/Guest.ts","../src/GuestPool.ts","../src/GuestInTheMiddle.ts","../src/Chain.ts","../src/Factory.ts","../src/FactoryDynamic.ts","../src/FactoryWithFactories.ts","../src/GuestAware.ts","../src/GuestCast.ts","../src/GuestSync.ts","../src/Patron.ts","../src/PatronOnce.ts","../src/Source.ts"],"sourcesContent":["import { PoolType } from \"./PoolType\";\nimport { GuestType, ReceiveOptions } from \"./GuestType\";\n\nconst poolSets = new Map<PoolType, Set<GuestType>>();\n\n/**\n * Удалить патрон из всех пулов\n */\nexport const removePatronFromPools = (patron: GuestType) => {\n poolSets.forEach((pool) => {\n pool.delete(patron);\n });\n};\n\nexport class PatronPool<T> implements PoolType<T> {\n private patrons = new Set<GuestType<T>>();\n\n public receive: (value: T, options?: ReceiveOptions) => this;\n\n public constructor(private initiator: unknown) {\n poolSets.set(this, this.patrons);\n\n let lastMicrotask: (() => void) | null = null;\n const doReceive = (value: T, options?: ReceiveOptions) => {\n this.patrons.forEach((target) => {\n this.sendValueToGuest(value, target, options);\n });\n };\n this.receive = (value: T, options?: ReceiveOptions) => {\n const currentMicroTask = () => {\n if (currentMicroTask === lastMicrotask) {\n doReceive(value, options);\n }\n };\n lastMicrotask = currentMicroTask;\n queueMicrotask(currentMicroTask);\n return this;\n };\n }\n\n public add(shouldBePatron: GuestType<T>) {\n if (\n shouldBePatron.introduction &&\n shouldBePatron.introduction() === \"patron\"\n ) {\n this.patrons.add(shouldBePatron);\n }\n return this;\n }\n\n public remove(patron: GuestType<T>) {\n this.patrons.delete(patron);\n return this;\n }\n\n public distribute(receiving: T, possiblePatron: GuestType<T>): this {\n this.add(possiblePatron);\n this.sendValueToGuest(receiving, possiblePatron, {});\n return this;\n }\n\n private sendValueToGuest(\n value: T,\n guest: GuestType<T>,\n options?: ReceiveOptions,\n ) {\n guest.receive(value, {\n ...options,\n data: {\n ...((options?.data as Record<string, unknown>) ?? {}),\n initiator: this.initiator,\n pool: this,\n },\n });\n }\n}\n","import { PatronPool } from \"./PatronPool\";\nimport { CacheType } from \"./CacheType\";\nimport { GuestType, ReceiveOptions } from \"./GuestType\";\n\nexport class Cache<T> implements CacheType<T> {\n private pool: PatronPool<T>;\n\n public constructor(\n initiator: unknown,\n private defaultValue: T | null = null,\n private theCache: T | null = null,\n ) {\n this.pool = new PatronPool<T>(initiator);\n }\n\n public receive(value: T, options?: ReceiveOptions): this {\n this.theCache = value;\n this.pool.receive(value, options);\n return this;\n }\n\n public receiving(guest: GuestType<T>): this {\n if (this.theCache !== null) {\n guest.receive(this.theCache);\n } else if (this.defaultValue !== null) {\n guest.receive(this.defaultValue);\n }\n this.pool.add(guest);\n return this;\n }\n}\n","import { GuestExecutorType } from \"./GuestExecutorType\";\nimport { GuestType, ReceiveOptions } from \"./GuestType\";\n\nexport class Guest<T> implements GuestType<T> {\n public constructor(private receiver: GuestExecutorType<T>) {}\n\n public receive(value: T, options?: ReceiveOptions) {\n this.receiver(value, options);\n return this;\n }\n}\n","import { PatronPool } from \"./PatronPool\";\nimport { PoolType } from \"./PoolType\";\nimport { GuestType, ReceiveOptions } from \"./GuestType\";\n\nexport class GuestPool<T> implements GuestType<T>, PoolType<T> {\n private guests = new Set<GuestType<T>>();\n\n private patronPool: PatronPool<T>;\n\n public constructor(initiator: unknown) {\n this.patronPool = new PatronPool(initiator);\n }\n\n public receive(value: T, options?: ReceiveOptions): this {\n this.deliverToGuests(value, options);\n this.patronPool.receive(value, options);\n return this;\n }\n\n public add(guest: GuestType<T>): this {\n if (!guest.introduction || guest.introduction() === \"guest\") {\n this.guests.add(guest);\n }\n this.patronPool.add(guest);\n return this;\n }\n\n public remove(patron: GuestType<T>): this {\n this.guests.delete(patron);\n this.patronPool.remove(patron);\n return this;\n }\n\n public distribute(receiving: T, possiblePatron: GuestType<T>): this {\n this.add(possiblePatron);\n this.receive(receiving);\n return this;\n }\n\n private deliverToGuests(value: T, options?: ReceiveOptions) {\n this.guests.forEach((target) => {\n target.receive(value, options);\n });\n this.guests.clear();\n }\n}\n","import { GuestType, ReceiveOptions } from \"./GuestType\";\n\nexport class GuestInTheMiddle<T> implements GuestType<T> {\n public constructor(\n private baseGuest: GuestType<unknown>,\n private middleFn: (value: T, options?: ReceiveOptions) => void,\n ) {}\n\n introduction() {\n if (!this.baseGuest.introduction) {\n return \"guest\";\n }\n return this.baseGuest.introduction();\n }\n\n receive(value: T, options?: ReceiveOptions): this {\n this.middleFn(value, options);\n return this;\n }\n}\n","import { Cache } from \"./Cache\";\nimport { Guest } from \"./Guest\";\nimport { GuestPool } from \"./GuestPool\";\nimport { ChainType } from \"./ChainType\";\nimport { GuestInTheMiddle } from \"./GuestInTheMiddle\";\nimport { GuestType } from \"./GuestType\";\n\nexport class Chain<T> implements ChainType<T> {\n private theChain: Cache<Record<string, unknown>>;\n\n private keysKnown = new Set();\n\n private keysFilled = new Set();\n\n private filledChainPool = new GuestPool(this);\n\n public constructor() {\n this.theChain = new Cache<Record<string, unknown>>(this, {});\n }\n\n public resultArray(guest: GuestType<T>) {\n this.filledChainPool.add(\n new GuestInTheMiddle(guest, (value: Record<string, unknown>) =>\n Object.values(value),\n ),\n );\n if (this.isChainFilled()) {\n this.theChain.receiving(\n new Guest((chain) => {\n this.filledChainPool.receive(Object.values(chain));\n }),\n );\n }\n\n return this;\n }\n\n public result(guest: GuestType<T>) {\n if (this.isChainFilled()) {\n this.filledChainPool.add(guest);\n this.theChain.receiving(\n new Guest((chain) => {\n this.filledChainPool.receive(chain);\n }),\n );\n } else {\n this.filledChainPool.add(guest);\n }\n return this;\n }\n\n public receiveKey<R>(key: string): GuestType<R> {\n this.keysKnown.add(key);\n return new Guest((value) => {\n // Обернул в очередь чтобы можно было синхронно наполнить очередь известных ключей\n queueMicrotask(() => {\n this.theChain.receiving(\n new Guest((chain) => {\n this.keysFilled.add(key);\n const lastChain = {\n ...chain,\n [key]: value,\n };\n this.theChain.receive(lastChain);\n if (this.isChainFilled()) {\n this.filledChainPool.receive(lastChain);\n }\n }),\n );\n });\n });\n }\n\n private isChainFilled() {\n return (\n this.keysFilled.size > 0 && this.keysFilled.size === this.keysKnown.size\n );\n }\n}\n","import { FactoryType } from \"./FactoryType\";\n\ninterface Constructable<T> {\n new (...args: unknown[]): T;\n}\n\ninterface Prototyped<T> {\n prototype: T;\n}\n\nexport class Factory<T> implements FactoryType<T> {\n public constructor(private constructorFn: Prototyped<T>) {}\n\n public create<R extends unknown[], CT = null>(\n ...args: R\n ): CT extends null ? T : CT {\n return new (this.constructorFn as Constructable<T>)(\n ...args,\n ) as CT extends null ? T : CT;\n }\n}\n","import { FactoryType } from \"./FactoryType\";\n\nexport class FactoryDynamic<T> implements FactoryType<T> {\n public constructor(private creationFn: (...args: unknown[]) => T) {}\n\n public create<R extends unknown[], CT = null>(\n ...args: R\n ): CT extends null ? T : CT {\n return this.creationFn(...args) as CT extends null ? T : CT;\n }\n}\n","import { FactoryType } from \"./FactoryType\";\n\ninterface Constructable<T> {\n new (...args: unknown[]): T;\n}\n\ninterface Prototyped<T> {\n prototype: T;\n}\n\nexport class FactoryWithFactories<T> implements FactoryType<T> {\n public constructor(\n private constructorFn: Prototyped<T>,\n private factories: Record<string, unknown> = {},\n ) {}\n\n public create<R extends unknown[], CT = null>(\n ...args: R\n ): CT extends null ? T : CT {\n return new (this.constructorFn as Constructable<T>)(\n ...args,\n this.factories,\n ) as CT extends null ? T : CT;\n }\n}\n","import { GuestType } from \"./GuestType\";\nimport { GuestAwareType } from \"./GuestAwareType\";\n\nexport class GuestAware<T = unknown> implements GuestAwareType<T> {\n public constructor(private guestReceiver: (guest: GuestType<T>) => void) {}\n\n public receiving(guest: GuestType<T>): GuestType<T> {\n this.guestReceiver(guest);\n return guest;\n }\n}\n","import { GuestType, ReceiveOptions } from \"./GuestType\";\n\nexport class GuestCast<T> implements GuestType<T> {\n public constructor(\n private sourceGuest: GuestType<unknown>,\n private targetGuest: GuestType<T>,\n ) {}\n\n introduction() {\n if (!this.sourceGuest.introduction) {\n return \"guest\";\n }\n return this.sourceGuest.introduction();\n }\n\n receive(value: T, options?: ReceiveOptions): this {\n this.targetGuest.receive(value, options);\n return this;\n }\n}\n","import { GuestValueType } from \"./GuestValueType\";\n\nexport class GuestSync<T> implements GuestValueType<T> {\n public constructor(private theValue: T) {}\n\n public receive(value: T): this {\n this.theValue = value;\n return this;\n }\n\n public value() {\n return this.theValue;\n }\n}\n","import { GuestType, ReceiveOptions } from \"./GuestType\";\n\n/**\n * Патрон - это постоянный посетитель\n */\nexport class Patron<T> implements GuestType<T> {\n public constructor(private willBePatron: GuestType<T>) {}\n\n public introduction() {\n return \"patron\" as const;\n }\n\n public receive(value: T, options?: ReceiveOptions): this {\n this.willBePatron.receive(value, options);\n return this;\n }\n}\n","import { GuestType, ReceiveOptions } from \"./GuestType\";\nimport { PoolType } from \"./PoolType\";\n\ntype PoolAware = {\n pool?: PoolType;\n};\n\nexport class PatronOnce<T> implements GuestType<T> {\n private received = false;\n\n public constructor(private baseGuest: GuestType<T>) {}\n\n public introduction() {\n return \"patron\" as const;\n }\n\n public receive(value: T, options?: ReceiveOptions): this {\n if (!this.received) {\n this.baseGuest.receive(value, options);\n }\n\n const data = options?.data as PoolAware;\n // Если есть пул, то удаляем себя из пула\n if (data?.pool) {\n data.pool.remove(this);\n }\n\n return this;\n }\n}\n","import { GuestType } from \"./GuestType\";\nimport { PatronPool } from \"./PatronPool\";\nimport { SourceType } from \"./SourceType\";\n\nexport class Source<T> implements SourceType<T> {\n private pool = new PatronPool(this);\n\n public constructor(private sourceDocument: T) {}\n\n public receive(value: T): this {\n this.sourceDocument = value;\n this.pool.receive(this.sourceDocument);\n return this;\n }\n\n public receiving(guest: GuestType<T>): this {\n this.pool.distribute(this.sourceDocument, guest);\n return this;\n }\n}\n"],"names":["__publicField"],"mappings":";;;;;AAGA,MAAM,QAAA,uBAAe,GAA8B,EAAA,CAAA;AAKtC,MAAA,qBAAA,GAAwB,CAAC,MAAsB,KAAA;AAC1D,EAAS,QAAA,CAAA,OAAA,CAAQ,CAAC,IAAS,KAAA;AACzB,IAAA,IAAA,CAAK,OAAO,MAAM,CAAA,CAAA;AAAA,GACnB,CAAA,CAAA;AACH,EAAA;AAEO,MAAM,UAAqC,CAAA;AAAA,EAKzC,YAAoB,SAAoB,EAAA;AAApB,IAAA,IAAA,CAAA,SAAA,GAAA,SAAA,CAAA;AAJ3B,IAAQA,eAAA,CAAA,IAAA,EAAA,SAAA,sBAAc,GAAkB,EAAA,CAAA,CAA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