patron-oop 1.4.0 → 1.5.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.
- package/CHANGELOG.md +10 -0
- package/dist/patron.d.ts +61 -79
- package/dist/patron.js +128 -127
- package/dist/patron.js.map +1 -1
- package/dist/patron.min.js +1 -1
- package/dist/patron.mjs +126 -118
- package/dist/patron.mjs.map +1 -1
- package/package.json +1 -1
- package/src/Guest/Guest.ts +45 -0
- package/src/Guest/GuestAware.test.ts +15 -0
- package/src/{GuestAware.ts → Guest/GuestAware.ts} +1 -1
- package/src/Guest/GuestCallback.test.ts +13 -0
- package/src/{Guest.ts → Guest/GuestCallback.ts} +1 -1
- package/src/Guest/GuestCast.test.ts +31 -0
- package/src/{GuestCast.ts → Guest/GuestCast.ts} +1 -1
- package/src/Guest/GuestChain.test.ts +72 -0
- package/src/{Chain.ts → Guest/GuestChain.ts} +9 -9
- package/src/Guest/GuestInTheMiddle.test.ts +71 -0
- package/src/{GuestInTheMiddle.ts → Guest/GuestInTheMiddle.ts} +1 -1
- package/src/{GuestPool.test.ts → Guest/GuestPool.test.ts} +7 -7
- package/src/{GuestPool.ts → Guest/GuestPool.ts} +3 -3
- package/src/Guest/GuestSync.test.ts +13 -0
- package/src/{GuestSync.ts → Guest/GuestSync.ts} +1 -1
- package/src/Patron/Patron.ts +18 -0
- package/src/{Patron.test.ts → Patron/PatronOfGuest.test.ts} +6 -6
- package/src/{Patron.ts → Patron/PatronOfGuest.ts} +2 -2
- package/src/{PatronOnce.test.ts → Patron/PatronOnce.test.ts} +4 -4
- package/src/{PatronOnce.ts → Patron/PatronOnce.ts} +2 -2
- package/src/{PatronPool.test.ts → Patron/PatronPool.test.ts} +6 -6
- package/src/{PatronPool.ts → Patron/PatronPool.ts} +7 -2
- package/src/Source/Source.ts +12 -0
- package/src/Source/SourceOfValue.test.ts +13 -0
- package/src/{Source.ts → Source/SourceOfValue.ts} +4 -4
- package/src/Source/SourcesApplied.test.ts +14 -0
- package/src/Source/SourcesApplied.ts +40 -0
- package/src/index.ts +9 -15
- package/src/Cache.test.ts +0 -20
- package/src/Cache.ts +0 -33
- package/src/Chain.test.ts +0 -72
- package/src/Factory.test.ts +0 -16
- package/src/Factory.ts +0 -23
- package/src/FactoryDynamic.ts +0 -11
- package/src/FactoryWithFactories.ts +0 -25
- package/src/Guest.test.ts +0 -13
- package/src/GuestInTheMiddle.test.ts +0 -71
- package/src/GuestSync.test.ts +0 -11
- package/src/PoolType.ts +0 -7
- package/src/Source.test.ts +0 -13
package/CHANGELOG.md
CHANGED
@@ -2,6 +2,16 @@
|
|
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.5.0](https://github.com/kosukhin/patron/compare/v1.4.0...v1.5.0) (2024-10-20)
|
6
|
+
|
7
|
+
|
8
|
+
### Features
|
9
|
+
|
10
|
+
* **issue-1:** доделал основные классы - фабрики ([a44fc85](https://github.com/kosukhin/patron/commit/a44fc853f7a1bd7ad8abf9428709eaec3d979b3f))
|
11
|
+
* **issue-1:** заготовка для фабрик основного функционала ([4f22d35](https://github.com/kosukhin/patron/commit/4f22d357188add1baf374c207b321f4c47e99997))
|
12
|
+
* **issue-1:** наработка для сорс апплиед ([c704597](https://github.com/kosukhin/patron/commit/c7045970265d843c77b6f657b60d629a1f0d3298))
|
13
|
+
* **main:** guest cast поправить ([211e05c](https://github.com/kosukhin/patron/commit/211e05c576b7c86b5d39537a8da5f5f83d071b46))
|
14
|
+
|
5
15
|
## [1.4.0](https://github.com/kosukhin/patron/compare/v1.3.0...v1.4.0) (2024-10-13)
|
6
16
|
|
7
17
|
|
package/dist/patron.d.ts
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
import { GuestAwareType as GuestAwareType$1 } from 'src/GuestAware';
|
2
|
-
|
3
1
|
type GuestIntroduction = "guest" | "patron";
|
4
2
|
interface ReceiveOptions {
|
5
3
|
data?: unknown;
|
@@ -9,37 +7,18 @@ interface GuestType<T = unknown> {
|
|
9
7
|
receive(value: T, options?: ReceiveOptions): this;
|
10
8
|
introduction?(): GuestIntroduction;
|
11
9
|
}
|
12
|
-
declare class
|
10
|
+
declare class GuestCallback<T> implements GuestType<T> {
|
13
11
|
private receiver;
|
14
12
|
constructor(receiver: GuestExecutorType<T>);
|
15
13
|
receive(value: T, options?: ReceiveOptions): this;
|
16
14
|
}
|
17
15
|
|
18
|
-
interface GuestAwareType<T = unknown> {
|
19
|
-
receiving(guest: GuestType<T>): unknown;
|
20
|
-
}
|
21
|
-
declare class GuestAware<T = unknown> implements GuestAwareType<T> {
|
22
|
-
private guestReceiver;
|
23
|
-
constructor(guestReceiver: (guest: GuestType<T>) => void);
|
24
|
-
receiving(guest: GuestType<T>): GuestType<T>;
|
25
|
-
}
|
26
|
-
|
27
|
-
type CacheType<T = unknown> = GuestType<T> & GuestAwareType<T>;
|
28
|
-
declare class Cache<T> implements CacheType<T> {
|
29
|
-
private defaultValue;
|
30
|
-
private theCache;
|
31
|
-
private pool;
|
32
|
-
constructor(initiator: unknown, defaultValue?: T | null, theCache?: T | null);
|
33
|
-
receive(value: T, options?: ReceiveOptions): this;
|
34
|
-
receiving(guest: GuestType<T>): this;
|
35
|
-
}
|
36
|
-
|
37
16
|
interface ChainType<T = unknown> {
|
38
17
|
result(guest: GuestType<T>): this;
|
39
18
|
resultArray(guest: GuestType<T>): this;
|
40
19
|
receiveKey<R>(key: string): GuestType<R>;
|
41
20
|
}
|
42
|
-
declare class
|
21
|
+
declare class GuestChain<T> implements ChainType<T> {
|
43
22
|
private theChain;
|
44
23
|
private keysKnown;
|
45
24
|
private keysFilled;
|
@@ -51,32 +30,52 @@ declare class Chain<T> implements ChainType<T> {
|
|
51
30
|
private isChainFilled;
|
52
31
|
}
|
53
32
|
|
54
|
-
interface
|
55
|
-
|
56
|
-
}
|
57
|
-
interface FactoryType<T> {
|
58
|
-
create<R extends unknown[], CT = null>(...args: R): CT extends null ? T : CT;
|
33
|
+
interface GuestValueType<T = unknown> extends GuestType<T> {
|
34
|
+
value(): T;
|
59
35
|
}
|
60
|
-
declare class
|
61
|
-
private
|
62
|
-
constructor(
|
63
|
-
|
36
|
+
declare class GuestSync<T> implements GuestValueType<T> {
|
37
|
+
private theValue;
|
38
|
+
constructor(theValue: T);
|
39
|
+
receive(value: T): this;
|
40
|
+
value(): T;
|
64
41
|
}
|
65
42
|
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
43
|
+
/**
|
44
|
+
* Удалить патрон из всех пулов
|
45
|
+
*/
|
46
|
+
declare const removePatronFromPools: (patron: GuestType) => void;
|
47
|
+
interface PoolType<T = unknown> extends GuestType<T> {
|
48
|
+
add(guest: GuestType<T>): this;
|
49
|
+
distribute(receiving: T, possiblePatron: GuestType<T>): this;
|
50
|
+
remove(patron: GuestType<T>): this;
|
51
|
+
}
|
52
|
+
declare class PatronPool<T> implements PoolType<T> {
|
53
|
+
private initiator;
|
54
|
+
private patrons;
|
55
|
+
receive: (value: T, options?: ReceiveOptions) => this;
|
56
|
+
constructor(initiator: unknown);
|
57
|
+
add(shouldBePatron: GuestType<T>): this;
|
58
|
+
remove(patron: GuestType<T>): this;
|
59
|
+
distribute(receiving: T, possiblePatron: GuestType<T>): this;
|
60
|
+
private sendValueToGuest;
|
70
61
|
}
|
71
62
|
|
72
|
-
interface
|
73
|
-
|
63
|
+
interface GuestAwareType<T = unknown> {
|
64
|
+
receiving(guest: GuestType<T>): unknown;
|
74
65
|
}
|
75
|
-
declare class
|
76
|
-
private
|
77
|
-
|
78
|
-
|
79
|
-
|
66
|
+
declare class GuestAware<T = unknown> implements GuestAwareType<T> {
|
67
|
+
private guestReceiver;
|
68
|
+
constructor(guestReceiver: (guest: GuestType<T>) => void);
|
69
|
+
receiving(guest: GuestType<T>): GuestType<T>;
|
70
|
+
}
|
71
|
+
|
72
|
+
type SourceType<T = unknown> = GuestAwareType<T> & GuestType<T>;
|
73
|
+
declare class SourceOfValue<T> implements SourceType<T> {
|
74
|
+
private sourceDocument;
|
75
|
+
private pool;
|
76
|
+
constructor(sourceDocument: T);
|
77
|
+
receive(value: T): this;
|
78
|
+
receiving(guest: GuestType<T>): this;
|
80
79
|
}
|
81
80
|
|
82
81
|
declare class GuestCast<T> implements GuestType<T> {
|
@@ -95,12 +94,6 @@ declare class GuestInTheMiddle<T> implements GuestType<T> {
|
|
95
94
|
receive(value: T, options?: ReceiveOptions): this;
|
96
95
|
}
|
97
96
|
|
98
|
-
interface PoolType<T = unknown> extends GuestType<T> {
|
99
|
-
add(guest: GuestType<T>): this;
|
100
|
-
distribute(receiving: T, possiblePatron: GuestType<T>): this;
|
101
|
-
remove(patron: GuestType<T>): this;
|
102
|
-
}
|
103
|
-
|
104
97
|
declare class GuestPool<T> implements GuestType<T>, PoolType<T> {
|
105
98
|
private guests;
|
106
99
|
private patronPool;
|
@@ -112,20 +105,20 @@ declare class GuestPool<T> implements GuestType<T>, PoolType<T> {
|
|
112
105
|
private deliverToGuests;
|
113
106
|
}
|
114
107
|
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
value
|
108
|
+
declare class Guest {
|
109
|
+
callback<P>(receiver: GuestExecutorType<P>): GuestCallback<P>;
|
110
|
+
chain(): GuestChain<unknown>;
|
111
|
+
cast<P>(sourceGuest: GuestType<unknown>, targetGuest: GuestType<P>): GuestCast<P>;
|
112
|
+
middleware<P>(baseGuest: GuestType<unknown>, middleFn: (value: P, options?: ReceiveOptions) => void): GuestInTheMiddle<P>;
|
113
|
+
pool(initiator: unknown): GuestPool<unknown>;
|
114
|
+
aware<P>(guestReceiver: (guest: GuestType<P>) => void): GuestAware<P>;
|
115
|
+
sync<P>(value: P): GuestSync<P>;
|
123
116
|
}
|
124
117
|
|
125
118
|
/**
|
126
119
|
* Патрон - это постоянный посетитель
|
127
120
|
*/
|
128
|
-
declare class
|
121
|
+
declare class PatronOfGuest<T> implements GuestType<T> {
|
129
122
|
private willBePatron;
|
130
123
|
constructor(willBePatron: GuestType<T>);
|
131
124
|
introduction(): "patron";
|
@@ -140,28 +133,17 @@ declare class PatronOnce<T> implements GuestType<T> {
|
|
140
133
|
receive(value: T, options?: ReceiveOptions): this;
|
141
134
|
}
|
142
135
|
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
declare class PatronPool<T> implements PoolType<T> {
|
148
|
-
private initiator;
|
149
|
-
private patrons;
|
150
|
-
receive: (value: T, options?: ReceiveOptions) => this;
|
151
|
-
constructor(initiator: unknown);
|
152
|
-
add(shouldBePatron: GuestType<T>): this;
|
153
|
-
remove(patron: GuestType<T>): this;
|
154
|
-
distribute(receiving: T, possiblePatron: GuestType<T>): this;
|
155
|
-
private sendValueToGuest;
|
136
|
+
declare class Patron {
|
137
|
+
ofGuest<P>(willBePatron: GuestType<P>): PatronOfGuest<P>;
|
138
|
+
once<P>(baseGuest: GuestType<P>): PatronOnce<P>;
|
139
|
+
pool(initiator: unknown): PatronPool<unknown>;
|
156
140
|
}
|
157
141
|
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
receive(value: T): this;
|
164
|
-
receiving(guest: GuestType<T>): this;
|
142
|
+
declare class Source {
|
143
|
+
ofValue<P>(sourceDocument: P): SourceOfValue<P>;
|
144
|
+
applySources<P>(target: P, methodsSources: Record<string, unknown[]>): {
|
145
|
+
[k: string]: any;
|
146
|
+
};
|
165
147
|
}
|
166
148
|
|
167
|
-
export {
|
149
|
+
export { type ChainType, Guest, GuestCallback, GuestChain, type GuestExecutorType, GuestSync, type GuestType, type GuestValueType, Patron, PatronPool, type PoolType, type ReceiveOptions, Source, SourceOfValue, type SourceType, removePatronFromPools };
|
package/dist/patron.js
CHANGED
@@ -1,8 +1,18 @@
|
|
1
1
|
'use strict';
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
3
|
+
class GuestCallback {
|
4
|
+
constructor(receiver) {
|
5
|
+
this.receiver = receiver;
|
6
|
+
}
|
7
|
+
receive(value, options) {
|
8
|
+
this.receiver(value, options);
|
9
|
+
return this;
|
10
|
+
}
|
11
|
+
}
|
12
|
+
|
13
|
+
var __defProp$4 = Object.defineProperty;
|
14
|
+
var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
15
|
+
var __publicField$4 = (obj, key, value) => __defNormalProp$4(obj, typeof key !== "symbol" ? key + "" : key, value);
|
6
16
|
const poolSets = /* @__PURE__ */ new Map();
|
7
17
|
const removePatronFromPools = (patron) => {
|
8
18
|
poolSets.forEach((pool) => {
|
@@ -12,8 +22,8 @@ const removePatronFromPools = (patron) => {
|
|
12
22
|
class PatronPool {
|
13
23
|
constructor(initiator) {
|
14
24
|
this.initiator = initiator;
|
15
|
-
__publicField$
|
16
|
-
__publicField$
|
25
|
+
__publicField$4(this, "patrons", /* @__PURE__ */ new Set());
|
26
|
+
__publicField$4(this, "receive");
|
17
27
|
poolSets.set(this, this.patrons);
|
18
28
|
let lastMicrotask = null;
|
19
29
|
const doReceive = (value, options) => {
|
@@ -59,42 +69,6 @@ class PatronPool {
|
|
59
69
|
}
|
60
70
|
}
|
61
71
|
|
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
72
|
var __defProp$3 = Object.defineProperty;
|
99
73
|
var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
100
74
|
var __publicField$3 = (obj, key, value) => __defNormalProp$3(obj, typeof key !== "symbol" ? key + "" : key, value);
|
@@ -153,14 +127,33 @@ class GuestInTheMiddle {
|
|
153
127
|
|
154
128
|
var __defProp$2 = Object.defineProperty;
|
155
129
|
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,
|
157
|
-
class
|
130
|
+
var __publicField$2 = (obj, key, value) => __defNormalProp$2(obj, key + "" , value);
|
131
|
+
class SourceOfValue {
|
132
|
+
constructor(sourceDocument) {
|
133
|
+
this.sourceDocument = sourceDocument;
|
134
|
+
__publicField$2(this, "pool", new PatronPool(this));
|
135
|
+
}
|
136
|
+
receive(value) {
|
137
|
+
this.sourceDocument = value;
|
138
|
+
this.pool.receive(this.sourceDocument);
|
139
|
+
return this;
|
140
|
+
}
|
141
|
+
receiving(guest) {
|
142
|
+
this.pool.distribute(this.sourceDocument, guest);
|
143
|
+
return this;
|
144
|
+
}
|
145
|
+
}
|
146
|
+
|
147
|
+
var __defProp$1 = Object.defineProperty;
|
148
|
+
var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
149
|
+
var __publicField$1 = (obj, key, value) => __defNormalProp$1(obj, typeof key !== "symbol" ? key + "" : key, value);
|
150
|
+
class GuestChain {
|
158
151
|
constructor() {
|
159
|
-
__publicField$
|
160
|
-
__publicField$
|
161
|
-
__publicField$
|
162
|
-
__publicField$
|
163
|
-
this.theChain = new
|
152
|
+
__publicField$1(this, "theChain");
|
153
|
+
__publicField$1(this, "keysKnown", /* @__PURE__ */ new Set());
|
154
|
+
__publicField$1(this, "keysFilled", /* @__PURE__ */ new Set());
|
155
|
+
__publicField$1(this, "filledChainPool", new GuestPool(this));
|
156
|
+
this.theChain = new SourceOfValue({});
|
164
157
|
}
|
165
158
|
resultArray(guest) {
|
166
159
|
this.filledChainPool.add(
|
@@ -171,7 +164,7 @@ class Chain {
|
|
171
164
|
);
|
172
165
|
if (this.isChainFilled()) {
|
173
166
|
this.theChain.receiving(
|
174
|
-
new
|
167
|
+
new GuestCallback((chain) => {
|
175
168
|
this.filledChainPool.receive(Object.values(chain));
|
176
169
|
})
|
177
170
|
);
|
@@ -182,7 +175,7 @@ class Chain {
|
|
182
175
|
if (this.isChainFilled()) {
|
183
176
|
this.filledChainPool.add(guest);
|
184
177
|
this.theChain.receiving(
|
185
|
-
new
|
178
|
+
new GuestCallback((chain) => {
|
186
179
|
this.filledChainPool.receive(chain);
|
187
180
|
})
|
188
181
|
);
|
@@ -193,10 +186,10 @@ class Chain {
|
|
193
186
|
}
|
194
187
|
receiveKey(key) {
|
195
188
|
this.keysKnown.add(key);
|
196
|
-
return new
|
189
|
+
return new GuestCallback((value) => {
|
197
190
|
queueMicrotask(() => {
|
198
191
|
this.theChain.receiving(
|
199
|
-
new
|
192
|
+
new GuestCallback((chain) => {
|
200
193
|
this.keysFilled.add(key);
|
201
194
|
const lastChain = {
|
202
195
|
...chain,
|
@@ -216,46 +209,16 @@ class Chain {
|
|
216
209
|
}
|
217
210
|
}
|
218
211
|
|
219
|
-
class
|
220
|
-
constructor(
|
221
|
-
this.
|
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
|
-
);
|
212
|
+
class GuestSync {
|
213
|
+
constructor(theValue) {
|
214
|
+
this.theValue = theValue;
|
249
215
|
}
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
constructor(guestReceiver) {
|
254
|
-
this.guestReceiver = guestReceiver;
|
216
|
+
receive(value) {
|
217
|
+
this.theValue = value;
|
218
|
+
return this;
|
255
219
|
}
|
256
|
-
|
257
|
-
this.
|
258
|
-
return guest;
|
220
|
+
value() {
|
221
|
+
return this.theValue;
|
259
222
|
}
|
260
223
|
}
|
261
224
|
|
@@ -276,20 +239,41 @@ class GuestCast {
|
|
276
239
|
}
|
277
240
|
}
|
278
241
|
|
279
|
-
class
|
280
|
-
constructor(
|
281
|
-
this.
|
242
|
+
class GuestAware {
|
243
|
+
constructor(guestReceiver) {
|
244
|
+
this.guestReceiver = guestReceiver;
|
282
245
|
}
|
283
|
-
|
284
|
-
this.
|
285
|
-
return
|
246
|
+
receiving(guest) {
|
247
|
+
this.guestReceiver(guest);
|
248
|
+
return guest;
|
286
249
|
}
|
287
|
-
|
288
|
-
|
250
|
+
}
|
251
|
+
|
252
|
+
class Guest {
|
253
|
+
callback(receiver) {
|
254
|
+
return new GuestCallback(receiver);
|
255
|
+
}
|
256
|
+
chain() {
|
257
|
+
return new GuestChain();
|
258
|
+
}
|
259
|
+
cast(sourceGuest, targetGuest) {
|
260
|
+
return new GuestCast(sourceGuest, targetGuest);
|
261
|
+
}
|
262
|
+
middleware(baseGuest, middleFn) {
|
263
|
+
return new GuestInTheMiddle(baseGuest, middleFn);
|
264
|
+
}
|
265
|
+
pool(initiator) {
|
266
|
+
return new GuestPool(initiator);
|
267
|
+
}
|
268
|
+
aware(guestReceiver) {
|
269
|
+
return new GuestAware(guestReceiver);
|
270
|
+
}
|
271
|
+
sync(value) {
|
272
|
+
return new GuestSync(value);
|
289
273
|
}
|
290
274
|
}
|
291
275
|
|
292
|
-
class
|
276
|
+
class PatronOfGuest {
|
293
277
|
constructor(willBePatron) {
|
294
278
|
this.willBePatron = willBePatron;
|
295
279
|
}
|
@@ -302,13 +286,13 @@ class Patron {
|
|
302
286
|
}
|
303
287
|
}
|
304
288
|
|
305
|
-
var __defProp
|
306
|
-
var __defNormalProp
|
307
|
-
var __publicField
|
289
|
+
var __defProp = Object.defineProperty;
|
290
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
291
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, key + "" , value);
|
308
292
|
class PatronOnce {
|
309
293
|
constructor(baseGuest) {
|
310
294
|
this.baseGuest = baseGuest;
|
311
|
-
__publicField
|
295
|
+
__publicField(this, "received", false);
|
312
296
|
}
|
313
297
|
introduction() {
|
314
298
|
return "patron";
|
@@ -325,39 +309,56 @@ class PatronOnce {
|
|
325
309
|
}
|
326
310
|
}
|
327
311
|
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
class Source {
|
332
|
-
constructor(sourceDocument) {
|
333
|
-
this.sourceDocument = sourceDocument;
|
334
|
-
__publicField(this, "pool", new PatronPool(this));
|
312
|
+
class Patron {
|
313
|
+
ofGuest(willBePatron) {
|
314
|
+
return new PatronOfGuest(willBePatron);
|
335
315
|
}
|
336
|
-
|
337
|
-
|
338
|
-
this.pool.receive(this.sourceDocument);
|
339
|
-
return this;
|
316
|
+
once(baseGuest) {
|
317
|
+
return new PatronOnce(baseGuest);
|
340
318
|
}
|
341
|
-
|
342
|
-
|
343
|
-
|
319
|
+
pool(initiator) {
|
320
|
+
return new PatronPool(initiator);
|
321
|
+
}
|
322
|
+
}
|
323
|
+
|
324
|
+
const sourcesApplied = (target, methodsSources) => {
|
325
|
+
return Object.fromEntries(
|
326
|
+
Object.entries(target).map(([key, value]) => {
|
327
|
+
if (value instanceof Function && methodsSources[key]) {
|
328
|
+
methodsSources[key];
|
329
|
+
return [
|
330
|
+
key,
|
331
|
+
new Proxy(value, {
|
332
|
+
apply(target2, thisArg, argArray) {
|
333
|
+
return target2.apply(thisArg, [
|
334
|
+
...methodsSources[key],
|
335
|
+
...argArray
|
336
|
+
]);
|
337
|
+
}
|
338
|
+
})
|
339
|
+
];
|
340
|
+
}
|
341
|
+
return [key, value];
|
342
|
+
})
|
343
|
+
);
|
344
|
+
};
|
345
|
+
|
346
|
+
class Source {
|
347
|
+
ofValue(sourceDocument) {
|
348
|
+
return new SourceOfValue(sourceDocument);
|
349
|
+
}
|
350
|
+
applySources(target, methodsSources) {
|
351
|
+
return sourcesApplied(target, methodsSources);
|
344
352
|
}
|
345
353
|
}
|
346
354
|
|
347
|
-
exports.Cache = Cache;
|
348
|
-
exports.Chain = Chain;
|
349
|
-
exports.Factory = Factory;
|
350
|
-
exports.FactoryDynamic = FactoryDynamic;
|
351
|
-
exports.FactoryWithFactories = FactoryWithFactories;
|
352
355
|
exports.Guest = Guest;
|
353
|
-
exports.
|
354
|
-
exports.
|
355
|
-
exports.GuestInTheMiddle = GuestInTheMiddle;
|
356
|
-
exports.GuestPool = GuestPool;
|
356
|
+
exports.GuestCallback = GuestCallback;
|
357
|
+
exports.GuestChain = GuestChain;
|
357
358
|
exports.GuestSync = GuestSync;
|
358
359
|
exports.Patron = Patron;
|
359
|
-
exports.PatronOnce = PatronOnce;
|
360
360
|
exports.PatronPool = PatronPool;
|
361
361
|
exports.Source = Source;
|
362
|
+
exports.SourceOfValue = SourceOfValue;
|
362
363
|
exports.removePatronFromPools = removePatronFromPools;
|
363
364
|
//# sourceMappingURL=patron.js.map
|