patron-oop 1.20.0 → 1.21.0
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +7 -0
- package/dist/patron.cjs +84 -73
- package/dist/patron.cjs.map +1 -1
- package/dist/patron.d.ts +22 -17
- package/dist/patron.js +84 -73
- package/dist/patron.js.map +1 -1
- package/dist/patron.min.js +1 -1
- package/dist/patron.min.mjs +1 -1
- package/dist/patron.min.mjs.map +1 -1
- package/dist/patron.mjs +84 -73
- package/dist/patron.mjs.map +1 -1
- package/package.json +1 -1
- package/src/Factory/Factory.test.ts +1 -1
- package/src/Guest/GuestCast.ts +0 -1
- package/src/Guest/GuestChain.ts +5 -6
- package/src/Guest/GuestDisposable.test.ts +30 -0
- package/src/Guest/GuestDisposable.ts +21 -0
- package/src/Patron/Patron.ts +8 -2
- package/src/Patron/PatronPool.ts +26 -9
- package/src/Source/SourceEmpty.ts +2 -2
- package/src/index.ts +2 -2
- package/src/Guest/GuestMiddle.test.ts +0 -71
- package/src/Guest/GuestMiddle.ts +0 -20
package/CHANGELOG.md
CHANGED
@@ -2,6 +2,13 @@
|
|
2
2
|
|
3
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
4
|
|
5
|
+
## [1.21.0](https://github.com/kosukhin/patron/compare/v1.20.0...v1.21.0) (2024-11-08)
|
6
|
+
|
7
|
+
|
8
|
+
### Features
|
9
|
+
|
10
|
+
* **main:** добавил проверку добавления в пул ([740e11b](https://github.com/kosukhin/patron/commit/740e11b086a34df0683ef632ade74b1440e95bef))
|
11
|
+
|
5
12
|
## [1.20.0](https://github.com/kosukhin/patron/compare/v1.19.0...v1.20.0) (2024-11-06)
|
6
13
|
|
7
14
|
|
package/dist/patron.cjs
CHANGED
@@ -90,6 +90,9 @@ class PatronPool {
|
|
90
90
|
};
|
91
91
|
}
|
92
92
|
add(shouldBePatron) {
|
93
|
+
if (!shouldBePatron) {
|
94
|
+
throw new Error("PatronPool add method received nothing!");
|
95
|
+
}
|
93
96
|
if (typeof shouldBePatron !== "function" && shouldBePatron.introduction && shouldBePatron.introduction() === "patron") {
|
94
97
|
this.patrons.add(shouldBePatron);
|
95
98
|
}
|
@@ -105,80 +108,34 @@ class PatronPool {
|
|
105
108
|
return this;
|
106
109
|
}
|
107
110
|
sendValueToGuest(value, guest, options) {
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
...options
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
}
|
118
|
-
|
119
|
-
var __defProp$4 = Object.defineProperty;
|
120
|
-
var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
121
|
-
var __publicField$4 = (obj, key, value) => __defNormalProp$4(obj, typeof key !== "symbol" ? key + "" : key, value);
|
122
|
-
class GuestPool {
|
123
|
-
constructor(initiator) {
|
124
|
-
__publicField$4(this, "guests", /* @__PURE__ */ new Set());
|
125
|
-
__publicField$4(this, "patronPool");
|
126
|
-
this.patronPool = new PatronPool(initiator);
|
127
|
-
}
|
128
|
-
give(value, options) {
|
129
|
-
this.deliverToGuests(value, options);
|
130
|
-
this.patronPool.give(value, options);
|
131
|
-
return this;
|
132
|
-
}
|
133
|
-
add(guest) {
|
134
|
-
if (typeof guest === "function" || !guest.introduction || guest.introduction() === "guest") {
|
135
|
-
this.guests.add(guest);
|
111
|
+
const isDisposed = this.guestDisposed(value, guest);
|
112
|
+
if (!isDisposed) {
|
113
|
+
give(value, guest, {
|
114
|
+
...options,
|
115
|
+
data: {
|
116
|
+
...options?.data ?? {},
|
117
|
+
initiator: this.initiator,
|
118
|
+
pool: this
|
119
|
+
}
|
120
|
+
});
|
136
121
|
}
|
137
|
-
this.patronPool.add(guest);
|
138
|
-
return this;
|
139
|
-
}
|
140
|
-
remove(patron) {
|
141
|
-
this.guests.delete(patron);
|
142
|
-
this.patronPool.remove(patron);
|
143
|
-
return this;
|
144
122
|
}
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
}
|
150
|
-
deliverToGuests(value, options) {
|
151
|
-
this.guests.forEach((target) => {
|
152
|
-
give(value, target, options);
|
153
|
-
});
|
154
|
-
this.guests.clear();
|
155
|
-
}
|
156
|
-
}
|
157
|
-
|
158
|
-
class GuestMiddle {
|
159
|
-
constructor(baseGuest, middleFn) {
|
160
|
-
this.baseGuest = baseGuest;
|
161
|
-
this.middleFn = middleFn;
|
162
|
-
}
|
163
|
-
introduction() {
|
164
|
-
if (typeof this.baseGuest === "function" || !this.baseGuest.introduction) {
|
165
|
-
return "guest";
|
123
|
+
guestDisposed(value, guest) {
|
124
|
+
if (guest.disposed?.(value)) {
|
125
|
+
this.remove(guest);
|
126
|
+
return true;
|
166
127
|
}
|
167
|
-
return
|
168
|
-
}
|
169
|
-
give(value, options) {
|
170
|
-
this.middleFn(value, options);
|
171
|
-
return this;
|
128
|
+
return false;
|
172
129
|
}
|
173
130
|
}
|
174
131
|
|
175
|
-
var __defProp$
|
176
|
-
var __defNormalProp$
|
177
|
-
var __publicField$
|
132
|
+
var __defProp$4 = Object.defineProperty;
|
133
|
+
var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
134
|
+
var __publicField$4 = (obj, key, value) => __defNormalProp$4(obj, key + "" , value);
|
178
135
|
class Source {
|
179
136
|
constructor(sourceDocument) {
|
180
137
|
this.sourceDocument = sourceDocument;
|
181
|
-
__publicField$
|
138
|
+
__publicField$4(this, "pool", new PatronPool(this));
|
182
139
|
}
|
183
140
|
give(value) {
|
184
141
|
this.sourceDocument = value;
|
@@ -215,6 +172,45 @@ class GuestObject {
|
|
215
172
|
}
|
216
173
|
}
|
217
174
|
|
175
|
+
var __defProp$3 = Object.defineProperty;
|
176
|
+
var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
177
|
+
var __publicField$3 = (obj, key, value) => __defNormalProp$3(obj, typeof key !== "symbol" ? key + "" : key, value);
|
178
|
+
class GuestPool {
|
179
|
+
constructor(initiator) {
|
180
|
+
__publicField$3(this, "guests", /* @__PURE__ */ new Set());
|
181
|
+
__publicField$3(this, "patronPool");
|
182
|
+
this.patronPool = new PatronPool(initiator);
|
183
|
+
}
|
184
|
+
give(value, options) {
|
185
|
+
this.deliverToGuests(value, options);
|
186
|
+
this.patronPool.give(value, options);
|
187
|
+
return this;
|
188
|
+
}
|
189
|
+
add(guest) {
|
190
|
+
if (typeof guest === "function" || !guest.introduction || guest.introduction() === "guest") {
|
191
|
+
this.guests.add(guest);
|
192
|
+
}
|
193
|
+
this.patronPool.add(guest);
|
194
|
+
return this;
|
195
|
+
}
|
196
|
+
remove(patron) {
|
197
|
+
this.guests.delete(patron);
|
198
|
+
this.patronPool.remove(patron);
|
199
|
+
return this;
|
200
|
+
}
|
201
|
+
distribute(receiving, possiblePatron) {
|
202
|
+
this.add(possiblePatron);
|
203
|
+
this.give(receiving);
|
204
|
+
return this;
|
205
|
+
}
|
206
|
+
deliverToGuests(value, options) {
|
207
|
+
this.guests.forEach((target) => {
|
208
|
+
give(value, target, options);
|
209
|
+
});
|
210
|
+
this.guests.clear();
|
211
|
+
}
|
212
|
+
}
|
213
|
+
|
218
214
|
var __defProp$2 = Object.defineProperty;
|
219
215
|
var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
220
216
|
var __publicField$2 = (obj, key, value) => __defNormalProp$2(obj, typeof key !== "symbol" ? key + "" : key, value);
|
@@ -229,12 +225,9 @@ class GuestChain {
|
|
229
225
|
resultArray(guest) {
|
230
226
|
const guestObject = new GuestObject(guest);
|
231
227
|
this.filledChainPool.add(
|
232
|
-
new
|
233
|
-
guestObject
|
234
|
-
|
235
|
-
guestObject.give(Object.values(value));
|
236
|
-
}
|
237
|
-
)
|
228
|
+
new GuestCast(guestObject, (value) => {
|
229
|
+
guestObject.give(Object.values(value));
|
230
|
+
})
|
238
231
|
);
|
239
232
|
if (this.isChainFilled()) {
|
240
233
|
this.theChain.value(
|
@@ -297,6 +290,20 @@ class GuestSync {
|
|
297
290
|
}
|
298
291
|
}
|
299
292
|
|
293
|
+
class GuestDisposable {
|
294
|
+
constructor(guest, disposeCheck) {
|
295
|
+
this.guest = guest;
|
296
|
+
this.disposeCheck = disposeCheck;
|
297
|
+
}
|
298
|
+
disposed(value) {
|
299
|
+
return this.disposeCheck(value);
|
300
|
+
}
|
301
|
+
give(value, options) {
|
302
|
+
give(value, this.guest, options);
|
303
|
+
return this;
|
304
|
+
}
|
305
|
+
}
|
306
|
+
|
300
307
|
class Patron {
|
301
308
|
constructor(willBePatron) {
|
302
309
|
this.willBePatron = willBePatron;
|
@@ -308,6 +315,10 @@ class Patron {
|
|
308
315
|
give(value, this.willBePatron, options);
|
309
316
|
return this;
|
310
317
|
}
|
318
|
+
disposed(value) {
|
319
|
+
const maybeDisposable = this.willBePatron;
|
320
|
+
return maybeDisposable?.disposed?.(value) || false;
|
321
|
+
}
|
311
322
|
}
|
312
323
|
|
313
324
|
var __defProp$1 = Object.defineProperty;
|
@@ -342,7 +353,7 @@ class SourceEmpty {
|
|
342
353
|
}
|
343
354
|
value(guest) {
|
344
355
|
this.baseSource.value(
|
345
|
-
new
|
356
|
+
new GuestCast(guest, (value) => {
|
346
357
|
if (value !== null) {
|
347
358
|
give(value, guest);
|
348
359
|
}
|
@@ -374,7 +385,7 @@ exports.Guest = Guest;
|
|
374
385
|
exports.GuestAware = GuestAware;
|
375
386
|
exports.GuestCast = GuestCast;
|
376
387
|
exports.GuestChain = GuestChain;
|
377
|
-
exports.
|
388
|
+
exports.GuestDisposable = GuestDisposable;
|
378
389
|
exports.GuestObject = GuestObject;
|
379
390
|
exports.GuestPool = GuestPool;
|
380
391
|
exports.GuestSync = GuestSync;
|
package/dist/patron.cjs.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"patron.cjs","sources":["../src/Guest/GuestAware.ts","../src/Guest/Guest.ts","../src/Guest/GuestCast.ts","../src/Patron/PatronPool.ts","../src/Guest/GuestPool.ts","../src/Guest/GuestMiddle.ts","../src/Source/Source.ts","../src/Guest/GuestObject.ts","../src/Guest/GuestChain.ts","../src/Guest/GuestSync.ts","../src/Patron/Patron.ts","../src/Patron/PatronOnce.ts","../src/Source/SourceEmpty.ts","../src/Factory/Factory.ts"],"sourcesContent":["import { GuestType } from \"./Guest\";\n\nexport interface GuestAwareType<T = unknown> {\n value(guest: GuestType<T>): unknown;\n}\n\nexport class GuestAware<T = unknown> implements GuestAwareType<T> {\n public constructor(private guestReceiver: (guest: GuestType<T>) => void) {}\n\n public value(guest: GuestType<T>): GuestType<T> {\n this.guestReceiver(guest);\n return guest;\n }\n}\n","type GuestIntroduction = \"guest\" | \"patron\";\n\nexport interface GiveOptions {\n data?: unknown;\n}\n\nexport type GuestExecutorType<T = unknown> = (\n value: T,\n options?: GiveOptions,\n) => void;\n\nexport interface GuestObjectType<T = unknown> {\n give(value: T, options?: GiveOptions): this;\n introduction?(): GuestIntroduction;\n}\n\nexport type GuestType<T = unknown> = GuestExecutorType<T> | GuestObjectType<T>;\n\nexport function give<T>(data: T, guest: GuestType<T>, options?: GiveOptions) {\n if (typeof guest === \"function\") {\n guest(data, options);\n } else {\n guest.give(data, options);\n }\n}\n\nexport class Guest<T> implements GuestObjectType<T> {\n public constructor(private receiver: GuestExecutorType<T>) {}\n\n public give(value: T, options?: GiveOptions) {\n this.receiver(value, options);\n return this;\n }\n}\n","import { give, GuestObjectType, GuestType, GiveOptions } from \"./Guest\";\n\n// TODO GuestMiddle - можно убрать т.к теперь этот класс делает то же самое и даже больше\nexport class GuestCast<T> implements GuestObjectType<T> {\n public constructor(\n private sourceGuest: GuestType<unknown>,\n private targetGuest: GuestType<T>,\n ) {}\n\n public introduction() {\n if (typeof this.sourceGuest === \"function\") {\n return \"guest\";\n }\n if (!this.sourceGuest.introduction) {\n return \"guest\";\n }\n return this.sourceGuest.introduction();\n }\n\n public give(value: T, options?: GiveOptions): this {\n give(value, this.targetGuest, options);\n return this;\n }\n}\n","import { give, GuestObjectType, GuestType, GiveOptions } from \"../Guest/Guest\";\n\nconst poolSets = new Map<PoolType, Set<GuestObjectType>>();\n\n// remove patron from all pools\nexport const removePatronFromPools = (patron: GuestObjectType) => {\n poolSets.forEach((pool) => {\n pool.delete(patron);\n });\n};\n\n// check patron existed in any pool\nexport const isPatronInPools = (patron: GuestObjectType) => {\n let inPool = false;\n poolSets.forEach((pool) => {\n if (!inPool) {\n inPool = pool.has(patron);\n }\n });\n return inPool;\n}\n\nexport interface PoolType<T = unknown> extends GuestObjectType<T> {\n add(guest: GuestObjectType<T>): this;\n distribute(receiving: T, possiblePatron: GuestObjectType<T>): this;\n remove(patron: GuestObjectType<T>): this;\n}\n\nexport class PatronPool<T> implements PoolType<T> {\n private patrons: Set<GuestObjectType<T>>;\n\n public give: (value: T, options?: GiveOptions) => this;\n\n public constructor(private initiator: unknown) {\n this.patrons = new Set<GuestObjectType<T>>();\n poolSets.set(this, this.patrons);\n let lastMicrotask: (() => void) | null = null;\n const doReceive = (value: T, options?: GiveOptions) => {\n this.patrons.forEach((target) => {\n this.sendValueToGuest(value, target, options);\n });\n };\n this.give = (value: T, options?: GiveOptions) => {\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 typeof shouldBePatron !== \"function\" &&\n shouldBePatron.introduction &&\n shouldBePatron.introduction() === \"patron\"\n ) {\n this.patrons.add(shouldBePatron);\n }\n return this;\n }\n\n public remove(patron: GuestObjectType<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?: GiveOptions,\n ) {\n give(value, guest, {\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 \"../Patron/PatronPool\";\nimport { PoolType } from \"../Patron/PatronPool\";\nimport { give, GuestObjectType, GuestType, GiveOptions } from \"./Guest\";\n\nexport class GuestPool<T> implements GuestObjectType<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 give(value: T, options?: GiveOptions): this {\n this.deliverToGuests(value, options);\n this.patronPool.give(value, options);\n return this;\n }\n\n public add(guest: GuestType<T>): this {\n if (\n typeof guest === \"function\" ||\n !guest.introduction ||\n guest.introduction() === \"guest\"\n ) {\n this.guests.add(guest);\n }\n this.patronPool.add(guest);\n return this;\n }\n\n public remove(patron: GuestObjectType<T>): this {\n this.guests.delete(patron);\n this.patronPool.remove(patron);\n return this;\n }\n\n public distribute(receiving: T, possiblePatron: GuestObjectType<T>): this {\n this.add(possiblePatron);\n this.give(receiving);\n return this;\n }\n\n private deliverToGuests(value: T, options?: GiveOptions) {\n this.guests.forEach((target) => {\n give(value, target, options);\n });\n this.guests.clear();\n }\n}\n","import { GuestObjectType, GuestType, GiveOptions } from \"./Guest\";\n\nexport class GuestMiddle<T> implements GuestObjectType<T> {\n public constructor(\n private baseGuest: GuestType<unknown>,\n private middleFn: (value: T, options?: GiveOptions) => void,\n ) {}\n\n public introduction() {\n if (typeof this.baseGuest === \"function\" || !this.baseGuest.introduction) {\n return \"guest\";\n }\n return this.baseGuest.introduction();\n }\n\n public give(value: T, options?: GiveOptions): this {\n this.middleFn(value, options);\n return this;\n }\n}\n","import { GuestAwareType } from \"../Guest/GuestAware\";\nimport { Guest, GuestObjectType, GuestType } from \"../Guest/Guest\";\nimport { PatronPool } from \"../Patron/PatronPool\";\n\nexport type SourceType<T = unknown> = GuestAwareType<T> & GuestObjectType<T>;\n\nexport class Source<T> implements SourceType<T> {\n private pool = new PatronPool(this);\n\n public constructor(private sourceDocument: T) {}\n\n public give(value: T): this {\n this.sourceDocument = value;\n this.pool.give(this.sourceDocument);\n return this;\n }\n\n public value(guest: GuestType<T>): this {\n if (typeof guest === \"function\") {\n this.pool.distribute(this.sourceDocument, new Guest(guest));\n } else {\n this.pool.distribute(this.sourceDocument, guest);\n }\n return this;\n }\n}\n","import { Guest, GuestObjectType, GuestType, GiveOptions } from \"./Guest\";\n\nexport class GuestObject<T> implements GuestObjectType<T> {\n public constructor(private baseGuest: GuestType<T>) {}\n\n public give(value: T, options?: GiveOptions): this {\n let guest = this.baseGuest;\n if (typeof guest === \"function\") {\n guest = new Guest(guest);\n }\n guest.give(value, options);\n return this;\n }\n\n public introduction() {\n if (typeof this.baseGuest === \"function\" || !this.baseGuest.introduction) {\n return \"guest\";\n }\n return this.baseGuest.introduction();\n }\n}\n","import { Guest, GuestObjectType, GuestType } from \"./Guest\";\nimport { GuestPool } from \"./GuestPool\";\nimport { GuestMiddle } from \"./GuestMiddle\";\nimport { Source } from \"../Source/Source\";\nimport { GuestObject } from \"./GuestObject\";\n\nexport interface ChainType<T = unknown> {\n result(guest: GuestObjectType<T>): this;\n resultArray(guest: GuestObjectType<T>): this;\n receiveKey<R>(key: string): GuestObjectType<R>;\n}\n\nexport class GuestChain<T> implements ChainType<T> {\n private theChain: Source<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 Source<Record<string, unknown>>({});\n }\n\n public resultArray(guest: GuestType<T>) {\n const guestObject = new GuestObject(guest);\n this.filledChainPool.add(\n new GuestMiddle(guestObject, (value: Record<string, unknown>) => {\n guestObject.give(Object.values(value) as T);\n }\n ),\n );\n if (this.isChainFilled()) {\n this.theChain.value(\n new Guest((chain: Record<string, unknown>) => {\n this.filledChainPool.give(Object.values(chain));\n }),\n );\n }\n return this;\n }\n\n public result(guest: GuestType<T>) {\n const guestObject = new GuestObject(guest);\n if (this.isChainFilled()) {\n this.filledChainPool.add(guestObject);\n this.theChain.value(\n new Guest((chain) => {\n this.filledChainPool.give(chain);\n }),\n );\n } else {\n this.filledChainPool.add(guestObject);\n }\n return this;\n }\n\n public receiveKey<R>(key: string): GuestObjectType<R> {\n this.keysKnown.add(key);\n return new Guest((value) => {\n // Обернул в очередь чтобы можно было синхронно наполнить очередь известных ключей\n queueMicrotask(() => {\n this.theChain.value(\n new Guest((chain: Record<string, unknown>) => {\n this.keysFilled.add(key);\n const lastChain = {\n ...chain,\n [key]: value,\n };\n this.theChain.give(lastChain);\n if (this.isChainFilled()) {\n this.filledChainPool.give(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 { GuestObjectType } from \"./Guest\";\n\nexport interface GuestValueType<T = unknown> extends GuestObjectType<T> {\n value(): T;\n}\n\nexport class GuestSync<T> implements GuestValueType<T> {\n public constructor(private theValue: T) {}\n\n public give(value: T): this {\n this.theValue = value;\n return this;\n }\n\n public value() {\n return this.theValue;\n }\n}\n","import { give, GuestObjectType, GuestType, GiveOptions } from \"../Guest/Guest\";\n\nexport class Patron<T> implements GuestObjectType<T> {\n public constructor(private willBePatron: GuestType<T>) {}\n\n public introduction() {\n return \"patron\" as const;\n }\n\n public give(value: T, options?: GiveOptions): this {\n give(value, this.willBePatron, options);\n return this;\n }\n}\n","import { PoolType } from \"./PatronPool\";\nimport { give, GuestObjectType, GuestType, GiveOptions } from \"../Guest/Guest\";\n\ntype PoolAware = {\n pool?: PoolType;\n};\n\nexport class PatronOnce<T> implements GuestObjectType<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 give(value: T, options?: GiveOptions): this {\n if (!this.received) {\n give(value, this.baseGuest, options);\n }\n const data = options?.data as PoolAware;\n if (data?.pool) {\n data.pool.remove(this);\n }\n return this;\n }\n}\n","import { give, GuestType } from \"./../Guest/Guest\";\nimport { GuestMiddle } from \"./../Guest/GuestMiddle\";\nimport { Source, SourceType } from \"./Source\";\n\nexport class SourceEmpty<T> implements SourceType<T> {\n private baseSource = new Source<T | null>(null);\n\n public value(guest: GuestType<T>) {\n this.baseSource.value(\n new GuestMiddle(guest as GuestType, (value) => {\n if (value !== null) {\n give(value, guest);\n }\n }),\n );\n return this;\n }\n\n public give(value: T): this {\n this.baseSource.give(value);\n return this;\n }\n}\n","interface Constructable<T> {\n new (...args: unknown[]): T;\n}\n\ninterface Prototyped<T> {\n prototype: T;\n}\n\nexport interface FactoryType<T> {\n create<R extends unknown[], CT = null>(...args: R): CT extends null ? T : CT;\n}\n\nexport class Factory<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"],"names":["__publicField"],"mappings":";;AAMO,MAAM,UAAqD,CAAA;AAAA,EACzD,YAAoB,aAA8C,EAAA;AAA9C,IAAA,IAAA,CAAA,aAAA,GAAA,aAAA,CAAA;AAAA,GAA+C;AAAA,EAEnE,MAAM,KAAmC,EAAA;AAC9C,IAAA,IAAA,CAAK,cAAc,KAAK,CAAA,CAAA;AACxB,IAAO,OAAA,KAAA,CAAA;AAAA,GACT;AACF;;ACKgB,SAAA,IAAA,CAAQ,IAAS,EAAA,KAAA,EAAqB,OAAuB,EAAA;AAC3E,EAAI,IAAA,OAAO,UAAU,UAAY,EAAA;AAC/B,IAAA,KAAA,CAAM,MAAM,OAAO,CAAA,CAAA;AAAA,GACd,MAAA;AACL,IAAM,KAAA,CA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OAAA,IAAA,CAAA;AAAA,GACT;AAAA,EAEO,KAAK,KAAgB,EAAA;AAC1B,IAAK,IAAA,CAAA,UAAA,CAAW,KAAK,KAAK,CAAA,CAAA;AAC1B,IAAO,OAAA,IAAA,CAAA;AAAA,GACT;AACF;;ACVO,MAAM,OAAqC,CAAA;AAAA,EACzC,WACG,CAAA,aAAA,EACA,SAAqC,GAAA,EAC7C,EAAA;AAFQ,IAAA,IAAA,CAAA,aAAA,GAAA,aAAA,CAAA;AACA,IAAA,IAAA,CAAA,SAAA,GAAA,SAAA,CAAA;AAAA,GACP;AAAA,EAEI,UACF,IACuB,EAAA;AAC1B,IAAA,OAAO,IAAK,IAAK,CAAA,aAAA;AAAA,MACf,GAAG,IAAA;AAAA,MACH,IAAK,CAAA,SAAA;AAAA,KACP,CAAA;AAAA,GACF;AACF;;;;;;;;;;;;;;;;;;;;"}
|
1
|
+
{"version":3,"file":"patron.cjs","sources":["../src/Guest/GuestAware.ts","../src/Guest/Guest.ts","../src/Guest/GuestCast.ts","../src/Patron/PatronPool.ts","../src/Source/Source.ts","../src/Guest/GuestObject.ts","../src/Guest/GuestPool.ts","../src/Guest/GuestChain.ts","../src/Guest/GuestSync.ts","../src/Guest/GuestDisposable.ts","../src/Patron/Patron.ts","../src/Patron/PatronOnce.ts","../src/Source/SourceEmpty.ts","../src/Factory/Factory.ts"],"sourcesContent":["import { GuestType } from \"./Guest\";\n\nexport interface GuestAwareType<T = unknown> {\n value(guest: GuestType<T>): unknown;\n}\n\nexport class GuestAware<T = unknown> implements GuestAwareType<T> {\n public constructor(private guestReceiver: (guest: GuestType<T>) => void) {}\n\n public value(guest: GuestType<T>): GuestType<T> {\n this.guestReceiver(guest);\n return guest;\n }\n}\n","type GuestIntroduction = \"guest\" | \"patron\";\n\nexport interface GiveOptions {\n data?: unknown;\n}\n\nexport type GuestExecutorType<T = unknown> = (\n value: T,\n options?: GiveOptions,\n) => void;\n\nexport interface GuestObjectType<T = unknown> {\n give(value: T, options?: GiveOptions): this;\n introduction?(): GuestIntroduction;\n}\n\nexport type GuestType<T = unknown> = GuestExecutorType<T> | GuestObjectType<T>;\n\nexport function give<T>(data: T, guest: GuestType<T>, options?: GiveOptions) {\n if (typeof guest === \"function\") {\n guest(data, options);\n } else {\n guest.give(data, options);\n }\n}\n\nexport class Guest<T> implements GuestObjectType<T> {\n public constructor(private receiver: GuestExecutorType<T>) {}\n\n public give(value: T, options?: GiveOptions) {\n this.receiver(value, options);\n return this;\n }\n}\n","import { give, GuestObjectType, GuestType, GiveOptions } from \"./Guest\";\n\nexport class GuestCast<T> implements GuestObjectType<T> {\n public constructor(\n private sourceGuest: GuestType<unknown>,\n private targetGuest: GuestType<T>,\n ) {}\n\n public introduction() {\n if (typeof this.sourceGuest === \"function\") {\n return \"guest\";\n }\n if (!this.sourceGuest.introduction) {\n return \"guest\";\n }\n return this.sourceGuest.introduction();\n }\n\n public give(value: T, options?: GiveOptions): this {\n give(value, this.targetGuest, options);\n return this;\n }\n}\n","import { GuestDisposableType } from \"../Guest/GuestDisposable\";\nimport { give, GuestObjectType, GuestType, GiveOptions } from \"../Guest/Guest\";\n\nconst poolSets = new Map<PoolType, Set<GuestObjectType>>();\n\n// remove patron from all pools\nexport const removePatronFromPools = (patron: GuestObjectType) => {\n poolSets.forEach((pool) => {\n pool.delete(patron);\n });\n};\n\n// check patron existed in any pool\nexport const isPatronInPools = (patron: GuestObjectType) => {\n let inPool = false;\n poolSets.forEach((pool) => {\n if (!inPool) {\n inPool = pool.has(patron);\n }\n });\n return inPool;\n};\n\nexport interface PoolType<T = unknown> extends GuestObjectType<T> {\n add(guest: GuestObjectType<T>): this;\n distribute(receiving: T, possiblePatron: GuestObjectType<T>): this;\n remove(patron: GuestObjectType<T>): this;\n}\n\nexport class PatronPool<T> implements PoolType<T> {\n private patrons: Set<GuestObjectType<T>>;\n\n public give: (value: T, options?: GiveOptions) => this;\n\n public constructor(private initiator: unknown) {\n this.patrons = new Set<GuestObjectType<T>>();\n poolSets.set(this, this.patrons);\n let lastMicrotask: (() => void) | null = null;\n const doReceive = (value: T, options?: GiveOptions) => {\n this.patrons.forEach((target) => {\n this.sendValueToGuest(value, target, options);\n });\n };\n this.give = (value: T, options?: GiveOptions) => {\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 (!shouldBePatron) {\n throw new Error(\"PatronPool add method received nothing!\");\n }\n if (\n typeof shouldBePatron !== \"function\" &&\n shouldBePatron.introduction &&\n shouldBePatron.introduction() === \"patron\"\n ) {\n this.patrons.add(shouldBePatron);\n }\n return this;\n }\n\n public remove(patron: GuestObjectType<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?: GiveOptions,\n ) {\n const isDisposed = this.guestDisposed(value, guest);\n\n if (!isDisposed) {\n give(value, guest, {\n ...options,\n data: {\n ...((options?.data as Record<string, unknown>) ?? {}),\n initiator: this.initiator,\n pool: this,\n },\n });\n }\n }\n\n private guestDisposed(value: T, guest: GuestType<T>) {\n if ((guest as GuestDisposableType).disposed?.(value)) {\n this.remove(guest as GuestObjectType);\n return true;\n }\n\n return false;\n }\n}\n","import { GuestAwareType } from \"../Guest/GuestAware\";\nimport { Guest, GuestObjectType, GuestType } from \"../Guest/Guest\";\nimport { PatronPool } from \"../Patron/PatronPool\";\n\nexport type SourceType<T = unknown> = GuestAwareType<T> & GuestObjectType<T>;\n\nexport class Source<T> implements SourceType<T> {\n private pool = new PatronPool(this);\n\n public constructor(private sourceDocument: T) {}\n\n public give(value: T): this {\n this.sourceDocument = value;\n this.pool.give(this.sourceDocument);\n return this;\n }\n\n public value(guest: GuestType<T>): this {\n if (typeof guest === \"function\") {\n this.pool.distribute(this.sourceDocument, new Guest(guest));\n } else {\n this.pool.distribute(this.sourceDocument, guest);\n }\n return this;\n }\n}\n","import { Guest, GuestObjectType, GuestType, GiveOptions } from \"./Guest\";\n\nexport class GuestObject<T> implements GuestObjectType<T> {\n public constructor(private baseGuest: GuestType<T>) {}\n\n public give(value: T, options?: GiveOptions): this {\n let guest = this.baseGuest;\n if (typeof guest === \"function\") {\n guest = new Guest(guest);\n }\n guest.give(value, options);\n return this;\n }\n\n public introduction() {\n if (typeof this.baseGuest === \"function\" || !this.baseGuest.introduction) {\n return \"guest\";\n }\n return this.baseGuest.introduction();\n }\n}\n","import { PatronPool } from \"../Patron/PatronPool\";\nimport { PoolType } from \"../Patron/PatronPool\";\nimport { give, GuestObjectType, GuestType, GiveOptions } from \"./Guest\";\n\nexport class GuestPool<T> implements GuestObjectType<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 give(value: T, options?: GiveOptions): this {\n this.deliverToGuests(value, options);\n this.patronPool.give(value, options);\n return this;\n }\n\n public add(guest: GuestType<T>): this {\n if (\n typeof guest === \"function\" ||\n !guest.introduction ||\n guest.introduction() === \"guest\"\n ) {\n this.guests.add(guest);\n }\n this.patronPool.add(guest);\n return this;\n }\n\n public remove(patron: GuestObjectType<T>): this {\n this.guests.delete(patron);\n this.patronPool.remove(patron);\n return this;\n }\n\n public distribute(receiving: T, possiblePatron: GuestObjectType<T>): this {\n this.add(possiblePatron);\n this.give(receiving);\n return this;\n }\n\n private deliverToGuests(value: T, options?: GiveOptions) {\n this.guests.forEach((target) => {\n give(value, target, options);\n });\n this.guests.clear();\n }\n}\n","import { GuestCast } from \"./GuestCast\";\nimport { Source } from \"../Source/Source\";\nimport { Guest, GuestObjectType, GuestType } from \"./Guest\";\nimport { GuestObject } from \"./GuestObject\";\nimport { GuestPool } from \"./GuestPool\";\n\nexport interface ChainType<T = unknown> {\n result(guest: GuestObjectType<T>): this;\n resultArray(guest: GuestObjectType<T>): this;\n receiveKey<R>(key: string): GuestObjectType<R>;\n}\n\nexport class GuestChain<T> implements ChainType<T> {\n private theChain: Source<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 Source<Record<string, unknown>>({});\n }\n\n public resultArray(guest: GuestType<T>) {\n const guestObject = new GuestObject(guest);\n this.filledChainPool.add(\n new GuestCast(guestObject, (value: Record<string, unknown>) => {\n guestObject.give(Object.values(value) as T);\n }),\n );\n if (this.isChainFilled()) {\n this.theChain.value(\n new Guest((chain: Record<string, unknown>) => {\n this.filledChainPool.give(Object.values(chain));\n }),\n );\n }\n return this;\n }\n\n public result(guest: GuestType<T>) {\n const guestObject = new GuestObject(guest);\n if (this.isChainFilled()) {\n this.filledChainPool.add(guestObject);\n this.theChain.value(\n new Guest((chain) => {\n this.filledChainPool.give(chain);\n }),\n );\n } else {\n this.filledChainPool.add(guestObject);\n }\n return this;\n }\n\n public receiveKey<R>(key: string): GuestObjectType<R> {\n this.keysKnown.add(key);\n return new Guest((value) => {\n // Обернул в очередь чтобы можно было синхронно наполнить очередь известных ключей\n queueMicrotask(() => {\n this.theChain.value(\n new Guest((chain: Record<string, unknown>) => {\n this.keysFilled.add(key);\n const lastChain = {\n ...chain,\n [key]: value,\n };\n this.theChain.give(lastChain);\n if (this.isChainFilled()) {\n this.filledChainPool.give(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 { GuestObjectType } from \"./Guest\";\n\nexport interface GuestValueType<T = unknown> extends GuestObjectType<T> {\n value(): T;\n}\n\nexport class GuestSync<T> implements GuestValueType<T> {\n public constructor(private theValue: T) {}\n\n public give(value: T): this {\n this.theValue = value;\n return this;\n }\n\n public value() {\n return this.theValue;\n }\n}\n","import { give, GiveOptions, GuestObjectType, GuestType } from \"./Guest\";\n\nexport interface GuestDisposableType<T = unknown> extends GuestObjectType<T> {\n disposed(value: T | null): boolean;\n}\n\nexport class GuestDisposable<T> implements GuestDisposableType<T> {\n public constructor(\n private guest: GuestType,\n private disposeCheck: (value: T | null) => boolean,\n ) {}\n\n public disposed(value: T | null): boolean {\n return this.disposeCheck(value);\n }\n\n public give(value: T, options?: GiveOptions): this {\n give(value, this.guest, options);\n return this;\n }\n}\n","import { GuestDisposableType } from \"../Guest/GuestDisposable\";\nimport { give, GiveOptions, GuestType } from \"../Guest/Guest\";\n\nexport class Patron<T> implements GuestDisposableType<T> {\n public constructor(private willBePatron: GuestType<T>) {}\n\n public introduction() {\n return \"patron\" as const;\n }\n\n public give(value: T, options?: GiveOptions): this {\n give(value, this.willBePatron, options);\n return this;\n }\n\n public disposed(value: T | null): boolean {\n const maybeDisposable = this.willBePatron as GuestDisposableType;\n return maybeDisposable?.disposed?.(value) || false;\n }\n}\n","import { PoolType } from \"./PatronPool\";\nimport { give, GuestObjectType, GuestType, GiveOptions } from \"../Guest/Guest\";\n\ntype PoolAware = {\n pool?: PoolType;\n};\n\nexport class PatronOnce<T> implements GuestObjectType<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 give(value: T, options?: GiveOptions): this {\n if (!this.received) {\n give(value, this.baseGuest, options);\n }\n const data = options?.data as PoolAware;\n if (data?.pool) {\n data.pool.remove(this);\n }\n return this;\n }\n}\n","import { GuestCast } from \"../Guest/GuestCast\";\nimport { give, GuestType } from \"./../Guest/Guest\";\nimport { Source, SourceType } from \"./Source\";\n\nexport class SourceEmpty<T> implements SourceType<T> {\n private baseSource = new Source<T | null>(null);\n\n public value(guest: GuestType<T>) {\n this.baseSource.value(\n new GuestCast(guest as GuestType, (value) => {\n if (value !== null) {\n give(value, guest);\n }\n }),\n );\n return this;\n }\n\n public give(value: T): this {\n this.baseSource.give(value);\n return this;\n }\n}\n","interface Constructable<T> {\n new (...args: unknown[]): T;\n}\n\ninterface Prototyped<T> {\n prototype: T;\n}\n\nexport interface FactoryType<T> {\n create<R extends unknown[], CT = null>(...args: R): CT extends null ? T : CT;\n}\n\nexport class Factory<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"],"names":["__publicField"],"mappings":";;AAMO,MAAM,UAAqD,CAAA;AAAA,EACzD,YAAoB,aAA8C,EAAA;AAA9C,IAAA,IAAA,CAAA,aAAA,GAAA,aAAA,CAAA;AAAA,GAA+C;AAAA,EAEnE,MAAM,KAAmC,EAAA;AAC9C,IAAA,IAAA,CAAK,cAAc,KAAK,CAAA,CAAA;AACxB,IAAO,OAAA,KAAA,CAAA;AAAA,GACT;AACF;;ACKgB,SAAA,IAAA,CAAQ,IAAS,EAAA,KAAA,EAAqB,OAAuB,EAAA;AAC3E,EAAI,IAAA,OAAO,UAAU,UAAY,EAAA;AAC/B,IAAA,KAAA,CAAM,MAAM,OAAO,CAAA,CAAA;AAAA,GACd,MAAA;AACL,IAAM,KAAA,CAAA,IAAA,CAAK,MAAM,OAAO,CAAA,CAAA;AAAA,GAC1B;AACF,CAAA;AAEO,MAAM,KAAuC,CAAA;AAAA,EAC3C,YAAoB,QAAgC,EAAA;AAAhC,IAAA,IAAA,CAAA,QAAA,GAAA,QAAA,CAAA;AAAA,GAAiC;AAAA,EAErD,IAAA,CAAK,OAAU,OAAuB,EAAA;AAC3C,IAAK,IAAA,CAAA,QAAA,CAAS,OAAO,OAAO,CAAA,CAAA;AAC5B,IAAO,OAAA,IAAA,CAAA;AAAA,GACT;AACF;;AC/BO,MAAM,SAA2C,CAAA;AAAA,EAC/C,WAAA,CAC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IAAI,UAAU,IAAM,EAAA;AAClB,UAAA,IAAA,CAAK,OAAO,KAAK,CAAA,CAAA;AAAA,SACnB;AAAA,OACD,CAAA;AAAA,KACH,CAAA;AACA,IAAO,OAAA,IAAA,CAAA;AAAA,GACT;AAAA,EAEO,KAAK,KAAgB,EAAA;AAC1B,IAAK,IAAA,CAAA,UAAA,CAAW,KAAK,KAAK,CAAA,CAAA;AAC1B,IAAO,OAAA,IAAA,CAAA;AAAA,GACT;AACF;;ACVO,MAAM,OAAqC,CAAA;AAAA,EACzC,WACG,CAAA,aAAA,EACA,SAAqC,GAAA,EAC7C,EAAA;AAFQ,IAAA,IAAA,CAAA,aAAA,GAAA,aAAA,CAAA;AACA,IAAA,IAAA,CAAA,SAAA,GAAA,SAAA,CAAA;AAAA,GACP;AAAA,EAEI,UACF,IACuB,EAAA;AAC1B,IAAA,OAAO,IAAK,IAAK,CAAA,aAAA;AAAA,MACf,GAAG,IAAA;AAAA,MACH,IAAK,CAAA,SAAA;AAAA,KACP,CAAA;AAAA,GACF;AACF;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/patron.d.ts
CHANGED
@@ -49,14 +49,6 @@ declare class GuestChain<T> implements ChainType<T> {
|
|
49
49
|
private isChainFilled;
|
50
50
|
}
|
51
51
|
|
52
|
-
declare class GuestMiddle<T> implements GuestObjectType<T> {
|
53
|
-
private baseGuest;
|
54
|
-
private middleFn;
|
55
|
-
constructor(baseGuest: GuestType<unknown>, middleFn: (value: T, options?: GiveOptions) => void);
|
56
|
-
introduction(): "guest" | "patron";
|
57
|
-
give(value: T, options?: GiveOptions): this;
|
58
|
-
}
|
59
|
-
|
60
52
|
declare const removePatronFromPools: (patron: GuestObjectType) => void;
|
61
53
|
declare const isPatronInPools: (patron: GuestObjectType) => boolean;
|
62
54
|
interface PoolType<T = unknown> extends GuestObjectType<T> {
|
@@ -73,6 +65,7 @@ declare class PatronPool<T> implements PoolType<T> {
|
|
73
65
|
remove(patron: GuestObjectType<T>): this;
|
74
66
|
distribute(receiving: T, possiblePatron: GuestType<T>): this;
|
75
67
|
private sendValueToGuest;
|
68
|
+
private guestDisposed;
|
76
69
|
}
|
77
70
|
|
78
71
|
declare class GuestPool<T> implements GuestObjectType<T>, PoolType<T> {
|
@@ -96,11 +89,30 @@ declare class GuestSync<T> implements GuestValueType<T> {
|
|
96
89
|
value(): T;
|
97
90
|
}
|
98
91
|
|
99
|
-
declare class
|
92
|
+
declare class GuestObject<T> implements GuestObjectType<T> {
|
93
|
+
private baseGuest;
|
94
|
+
constructor(baseGuest: GuestType<T>);
|
95
|
+
give(value: T, options?: GiveOptions): this;
|
96
|
+
introduction(): "guest" | "patron";
|
97
|
+
}
|
98
|
+
|
99
|
+
interface GuestDisposableType<T = unknown> extends GuestObjectType<T> {
|
100
|
+
disposed(value: T | null): boolean;
|
101
|
+
}
|
102
|
+
declare class GuestDisposable<T> implements GuestDisposableType<T> {
|
103
|
+
private guest;
|
104
|
+
private disposeCheck;
|
105
|
+
constructor(guest: GuestType, disposeCheck: (value: T | null) => boolean);
|
106
|
+
disposed(value: T | null): boolean;
|
107
|
+
give(value: T, options?: GiveOptions): this;
|
108
|
+
}
|
109
|
+
|
110
|
+
declare class Patron<T> implements GuestDisposableType<T> {
|
100
111
|
private willBePatron;
|
101
112
|
constructor(willBePatron: GuestType<T>);
|
102
113
|
introduction(): "patron";
|
103
114
|
give(value: T, options?: GiveOptions): this;
|
115
|
+
disposed(value: T | null): boolean;
|
104
116
|
}
|
105
117
|
|
106
118
|
declare class PatronOnce<T> implements GuestObjectType<T> {
|
@@ -126,13 +138,6 @@ declare class SourceEmpty<T> implements SourceType<T> {
|
|
126
138
|
give(value: T): this;
|
127
139
|
}
|
128
140
|
|
129
|
-
declare class GuestObject<T> implements GuestObjectType<T> {
|
130
|
-
private baseGuest;
|
131
|
-
constructor(baseGuest: GuestType<T>);
|
132
|
-
give(value: T, options?: GiveOptions): this;
|
133
|
-
introduction(): "guest" | "patron";
|
134
|
-
}
|
135
|
-
|
136
141
|
interface Prototyped<T> {
|
137
142
|
prototype: T;
|
138
143
|
}
|
@@ -146,4 +151,4 @@ declare class Factory<T> implements FactoryType<T> {
|
|
146
151
|
create<R extends unknown[], CT = null>(...args: R): CT extends null ? T : CT;
|
147
152
|
}
|
148
153
|
|
149
|
-
export { type ChainType, Factory, type FactoryType, type GiveOptions, Guest, GuestAware, type GuestAwareType, GuestCast, GuestChain, type
|
154
|
+
export { type ChainType, Factory, type FactoryType, type GiveOptions, Guest, GuestAware, type GuestAwareType, GuestCast, GuestChain, GuestDisposable, type GuestDisposableType, type GuestExecutorType, GuestObject, type GuestObjectType, GuestPool, GuestSync, type GuestType, type GuestValueType, Patron, PatronOnce, PatronPool, type PoolType, Source, SourceEmpty, type SourceType, give, isPatronInPools, removePatronFromPools };
|
package/dist/patron.js
CHANGED
@@ -88,6 +88,9 @@ class PatronPool {
|
|
88
88
|
};
|
89
89
|
}
|
90
90
|
add(shouldBePatron) {
|
91
|
+
if (!shouldBePatron) {
|
92
|
+
throw new Error("PatronPool add method received nothing!");
|
93
|
+
}
|
91
94
|
if (typeof shouldBePatron !== "function" && shouldBePatron.introduction && shouldBePatron.introduction() === "patron") {
|
92
95
|
this.patrons.add(shouldBePatron);
|
93
96
|
}
|
@@ -103,80 +106,34 @@ class PatronPool {
|
|
103
106
|
return this;
|
104
107
|
}
|
105
108
|
sendValueToGuest(value, guest, options) {
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
...options
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
}
|
116
|
-
|
117
|
-
var __defProp$4 = Object.defineProperty;
|
118
|
-
var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
119
|
-
var __publicField$4 = (obj, key, value) => __defNormalProp$4(obj, typeof key !== "symbol" ? key + "" : key, value);
|
120
|
-
class GuestPool {
|
121
|
-
constructor(initiator) {
|
122
|
-
__publicField$4(this, "guests", /* @__PURE__ */ new Set());
|
123
|
-
__publicField$4(this, "patronPool");
|
124
|
-
this.patronPool = new PatronPool(initiator);
|
125
|
-
}
|
126
|
-
give(value, options) {
|
127
|
-
this.deliverToGuests(value, options);
|
128
|
-
this.patronPool.give(value, options);
|
129
|
-
return this;
|
130
|
-
}
|
131
|
-
add(guest) {
|
132
|
-
if (typeof guest === "function" || !guest.introduction || guest.introduction() === "guest") {
|
133
|
-
this.guests.add(guest);
|
109
|
+
const isDisposed = this.guestDisposed(value, guest);
|
110
|
+
if (!isDisposed) {
|
111
|
+
give(value, guest, {
|
112
|
+
...options,
|
113
|
+
data: {
|
114
|
+
...options?.data ?? {},
|
115
|
+
initiator: this.initiator,
|
116
|
+
pool: this
|
117
|
+
}
|
118
|
+
});
|
134
119
|
}
|
135
|
-
this.patronPool.add(guest);
|
136
|
-
return this;
|
137
|
-
}
|
138
|
-
remove(patron) {
|
139
|
-
this.guests.delete(patron);
|
140
|
-
this.patronPool.remove(patron);
|
141
|
-
return this;
|
142
120
|
}
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
}
|
148
|
-
deliverToGuests(value, options) {
|
149
|
-
this.guests.forEach((target) => {
|
150
|
-
give(value, target, options);
|
151
|
-
});
|
152
|
-
this.guests.clear();
|
153
|
-
}
|
154
|
-
}
|
155
|
-
|
156
|
-
class GuestMiddle {
|
157
|
-
constructor(baseGuest, middleFn) {
|
158
|
-
this.baseGuest = baseGuest;
|
159
|
-
this.middleFn = middleFn;
|
160
|
-
}
|
161
|
-
introduction() {
|
162
|
-
if (typeof this.baseGuest === "function" || !this.baseGuest.introduction) {
|
163
|
-
return "guest";
|
121
|
+
guestDisposed(value, guest) {
|
122
|
+
if (guest.disposed?.(value)) {
|
123
|
+
this.remove(guest);
|
124
|
+
return true;
|
164
125
|
}
|
165
|
-
return
|
166
|
-
}
|
167
|
-
give(value, options) {
|
168
|
-
this.middleFn(value, options);
|
169
|
-
return this;
|
126
|
+
return false;
|
170
127
|
}
|
171
128
|
}
|
172
129
|
|
173
|
-
var __defProp$
|
174
|
-
var __defNormalProp$
|
175
|
-
var __publicField$
|
130
|
+
var __defProp$4 = Object.defineProperty;
|
131
|
+
var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
132
|
+
var __publicField$4 = (obj, key, value) => __defNormalProp$4(obj, key + "" , value);
|
176
133
|
class Source {
|
177
134
|
constructor(sourceDocument) {
|
178
135
|
this.sourceDocument = sourceDocument;
|
179
|
-
__publicField$
|
136
|
+
__publicField$4(this, "pool", new PatronPool(this));
|
180
137
|
}
|
181
138
|
give(value) {
|
182
139
|
this.sourceDocument = value;
|
@@ -213,6 +170,45 @@ class GuestObject {
|
|
213
170
|
}
|
214
171
|
}
|
215
172
|
|
173
|
+
var __defProp$3 = Object.defineProperty;
|
174
|
+
var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
175
|
+
var __publicField$3 = (obj, key, value) => __defNormalProp$3(obj, typeof key !== "symbol" ? key + "" : key, value);
|
176
|
+
class GuestPool {
|
177
|
+
constructor(initiator) {
|
178
|
+
__publicField$3(this, "guests", /* @__PURE__ */ new Set());
|
179
|
+
__publicField$3(this, "patronPool");
|
180
|
+
this.patronPool = new PatronPool(initiator);
|
181
|
+
}
|
182
|
+
give(value, options) {
|
183
|
+
this.deliverToGuests(value, options);
|
184
|
+
this.patronPool.give(value, options);
|
185
|
+
return this;
|
186
|
+
}
|
187
|
+
add(guest) {
|
188
|
+
if (typeof guest === "function" || !guest.introduction || guest.introduction() === "guest") {
|
189
|
+
this.guests.add(guest);
|
190
|
+
}
|
191
|
+
this.patronPool.add(guest);
|
192
|
+
return this;
|
193
|
+
}
|
194
|
+
remove(patron) {
|
195
|
+
this.guests.delete(patron);
|
196
|
+
this.patronPool.remove(patron);
|
197
|
+
return this;
|
198
|
+
}
|
199
|
+
distribute(receiving, possiblePatron) {
|
200
|
+
this.add(possiblePatron);
|
201
|
+
this.give(receiving);
|
202
|
+
return this;
|
203
|
+
}
|
204
|
+
deliverToGuests(value, options) {
|
205
|
+
this.guests.forEach((target) => {
|
206
|
+
give(value, target, options);
|
207
|
+
});
|
208
|
+
this.guests.clear();
|
209
|
+
}
|
210
|
+
}
|
211
|
+
|
216
212
|
var __defProp$2 = Object.defineProperty;
|
217
213
|
var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
218
214
|
var __publicField$2 = (obj, key, value) => __defNormalProp$2(obj, typeof key !== "symbol" ? key + "" : key, value);
|
@@ -227,12 +223,9 @@ class GuestChain {
|
|
227
223
|
resultArray(guest) {
|
228
224
|
const guestObject = new GuestObject(guest);
|
229
225
|
this.filledChainPool.add(
|
230
|
-
new
|
231
|
-
guestObject
|
232
|
-
|
233
|
-
guestObject.give(Object.values(value));
|
234
|
-
}
|
235
|
-
)
|
226
|
+
new GuestCast(guestObject, (value) => {
|
227
|
+
guestObject.give(Object.values(value));
|
228
|
+
})
|
236
229
|
);
|
237
230
|
if (this.isChainFilled()) {
|
238
231
|
this.theChain.value(
|
@@ -295,6 +288,20 @@ class GuestSync {
|
|
295
288
|
}
|
296
289
|
}
|
297
290
|
|
291
|
+
class GuestDisposable {
|
292
|
+
constructor(guest, disposeCheck) {
|
293
|
+
this.guest = guest;
|
294
|
+
this.disposeCheck = disposeCheck;
|
295
|
+
}
|
296
|
+
disposed(value) {
|
297
|
+
return this.disposeCheck(value);
|
298
|
+
}
|
299
|
+
give(value, options) {
|
300
|
+
give(value, this.guest, options);
|
301
|
+
return this;
|
302
|
+
}
|
303
|
+
}
|
304
|
+
|
298
305
|
class Patron {
|
299
306
|
constructor(willBePatron) {
|
300
307
|
this.willBePatron = willBePatron;
|
@@ -306,6 +313,10 @@ class Patron {
|
|
306
313
|
give(value, this.willBePatron, options);
|
307
314
|
return this;
|
308
315
|
}
|
316
|
+
disposed(value) {
|
317
|
+
const maybeDisposable = this.willBePatron;
|
318
|
+
return maybeDisposable?.disposed?.(value) || false;
|
319
|
+
}
|
309
320
|
}
|
310
321
|
|
311
322
|
var __defProp$1 = Object.defineProperty;
|
@@ -340,7 +351,7 @@ class SourceEmpty {
|
|
340
351
|
}
|
341
352
|
value(guest) {
|
342
353
|
this.baseSource.value(
|
343
|
-
new
|
354
|
+
new GuestCast(guest, (value) => {
|
344
355
|
if (value !== null) {
|
345
356
|
give(value, guest);
|
346
357
|
}
|
@@ -367,5 +378,5 @@ class Factory {
|
|
367
378
|
}
|
368
379
|
}
|
369
380
|
|
370
|
-
export { Factory, Guest, GuestAware, GuestCast, GuestChain,
|
381
|
+
export { Factory, Guest, GuestAware, GuestCast, GuestChain, GuestDisposable, GuestObject, GuestPool, GuestSync, Patron, PatronOnce, PatronPool, Source, SourceEmpty, give, isPatronInPools, removePatronFromPools };
|
371
382
|
//# sourceMappingURL=patron.js.map
|