patron-oop 1.3.0 → 1.5.0
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +18 -0
- package/README.md +60 -0
- package/dist/patron.d.ts +59 -83
- 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} +5 -2
- package/src/Guest/GuestCallback.test.ts +13 -0
- package/src/Guest/GuestCallback.ts +21 -0
- 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} +15 -11
- 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} +5 -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} +3 -3
- 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} +6 -4
- package/src/Source/SourcesApplied.test.ts +14 -0
- package/src/Source/SourcesApplied.ts +40 -0
- package/src/index.ts +9 -16
- package/src/Cache.test.ts +0 -20
- package/src/Cache.ts +0 -31
- package/src/CacheType.ts +0 -4
- package/src/Chain.test.ts +0 -72
- package/src/ChainType.ts +0 -7
- package/src/Factory.test.ts +0 -16
- package/src/Factory.ts +0 -21
- package/src/FactoryDynamic.ts +0 -11
- package/src/FactoryType.ts +0 -3
- package/src/FactoryWithFactories.ts +0 -25
- package/src/Guest.test.ts +0 -13
- package/src/Guest.ts +0 -11
- package/src/GuestAwareType.ts +0 -5
- package/src/GuestExecutorType.ts +0 -3
- package/src/GuestInTheMiddle.test.ts +0 -71
- package/src/GuestSync.test.ts +0 -11
- package/src/GuestType.ts +0 -10
- package/src/GuestValueType.ts +0 -5
- package/src/PoolType.ts +0 -7
- package/src/Source.test.ts +0 -13
- package/src/SourceType.ts +0 -4
package/CHANGELOG.md
CHANGED
@@ -2,6 +2,24 @@
|
|
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
|
+
|
15
|
+
## [1.4.0](https://github.com/kosukhin/patron/compare/v1.3.0...v1.4.0) (2024-10-13)
|
16
|
+
|
17
|
+
|
18
|
+
### Features
|
19
|
+
|
20
|
+
* **main:** заготовка для описания каждого класса ([03344dd](https://github.com/kosukhin/patron/commit/03344dd86952422e055c581a5b38944d89240db1))
|
21
|
+
* **main:** убрать типы из отдельных файлов ([1b27b36](https://github.com/kosukhin/patron/commit/1b27b36870a3fb07ce5eb875f88a88d6efa86e65))
|
22
|
+
|
5
23
|
## [1.3.0](https://github.com/kosukhin/patron/compare/v1.2.1...v1.3.0) (2024-10-13)
|
6
24
|
|
7
25
|
|
package/README.md
CHANGED
@@ -7,3 +7,63 @@ Patron JS - это библиотека для ООП программирова
|
|
7
7
|
|
8
8
|
Patron - это сущность, которая является посетителем какого-либо объекта и приходит к объекту за результатом вычисления.
|
9
9
|
Guest - это почти такая же сущность как и Patron, разница только в том что Patron нужно постоянно уведомлять об изменениях а Guest не нужно.
|
10
|
+
|
11
|
+
# Guest
|
12
|
+
|
13
|
+
TODO
|
14
|
+
|
15
|
+
# GuestAware
|
16
|
+
|
17
|
+
TODO
|
18
|
+
|
19
|
+
# GuestCast
|
20
|
+
|
21
|
+
TODO
|
22
|
+
|
23
|
+
# GuestInTheMiddle
|
24
|
+
|
25
|
+
TODO
|
26
|
+
|
27
|
+
# GuestPool
|
28
|
+
|
29
|
+
TODO
|
30
|
+
|
31
|
+
# GuestSync
|
32
|
+
|
33
|
+
TODO
|
34
|
+
|
35
|
+
# Patron
|
36
|
+
|
37
|
+
TODO
|
38
|
+
|
39
|
+
# PatronOnce
|
40
|
+
|
41
|
+
TODO
|
42
|
+
|
43
|
+
# PatronPool
|
44
|
+
|
45
|
+
TODO
|
46
|
+
|
47
|
+
# Source
|
48
|
+
|
49
|
+
TODO
|
50
|
+
|
51
|
+
# Factory
|
52
|
+
|
53
|
+
TODO
|
54
|
+
|
55
|
+
# FactoryDynamic
|
56
|
+
|
57
|
+
TODO
|
58
|
+
|
59
|
+
# FactoryWithFactories
|
60
|
+
|
61
|
+
TODO
|
62
|
+
|
63
|
+
# Chain
|
64
|
+
|
65
|
+
TODO
|
66
|
+
|
67
|
+
# Cache
|
68
|
+
|
69
|
+
TODO
|
package/dist/patron.d.ts
CHANGED
@@ -2,24 +2,15 @@ type GuestIntroduction = "guest" | "patron";
|
|
2
2
|
interface ReceiveOptions {
|
3
3
|
data?: unknown;
|
4
4
|
}
|
5
|
+
type GuestExecutorType<T> = (value: T, options?: ReceiveOptions) => void;
|
5
6
|
interface GuestType<T = unknown> {
|
6
7
|
receive(value: T, options?: ReceiveOptions): this;
|
7
8
|
introduction?(): GuestIntroduction;
|
8
9
|
}
|
9
|
-
|
10
|
-
|
11
|
-
|
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);
|
10
|
+
declare class GuestCallback<T> implements GuestType<T> {
|
11
|
+
private receiver;
|
12
|
+
constructor(receiver: GuestExecutorType<T>);
|
21
13
|
receive(value: T, options?: ReceiveOptions): this;
|
22
|
-
receiving(guest: GuestType<T>): this;
|
23
14
|
}
|
24
15
|
|
25
16
|
interface ChainType<T = unknown> {
|
@@ -27,8 +18,7 @@ interface ChainType<T = unknown> {
|
|
27
18
|
resultArray(guest: GuestType<T>): this;
|
28
19
|
receiveKey<R>(key: string): GuestType<R>;
|
29
20
|
}
|
30
|
-
|
31
|
-
declare class Chain<T> implements ChainType<T> {
|
21
|
+
declare class GuestChain<T> implements ChainType<T> {
|
32
22
|
private theChain;
|
33
23
|
private keysKnown;
|
34
24
|
private keysFilled;
|
@@ -40,49 +30,54 @@ declare class Chain<T> implements ChainType<T> {
|
|
40
30
|
private isChainFilled;
|
41
31
|
}
|
42
32
|
|
43
|
-
interface
|
44
|
-
|
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;
|
33
|
+
interface GuestValueType<T = unknown> extends GuestType<T> {
|
34
|
+
value(): T;
|
54
35
|
}
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
36
|
+
declare class GuestSync<T> implements GuestValueType<T> {
|
37
|
+
private theValue;
|
38
|
+
constructor(theValue: T);
|
39
|
+
receive(value: T): this;
|
40
|
+
value(): T;
|
60
41
|
}
|
61
42
|
|
62
|
-
|
63
|
-
|
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;
|
64
51
|
}
|
65
|
-
declare class
|
66
|
-
private
|
67
|
-
private
|
68
|
-
|
69
|
-
|
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
|
-
|
73
|
-
|
74
|
-
declare class Guest<T> implements GuestType<T> {
|
75
|
-
private receiver;
|
76
|
-
constructor(receiver: GuestExecutorType<T>);
|
77
|
-
receive(value: T, options?: ReceiveOptions): this;
|
63
|
+
interface GuestAwareType<T = unknown> {
|
64
|
+
receiving(guest: GuestType<T>): unknown;
|
78
65
|
}
|
79
|
-
|
80
66
|
declare class GuestAware<T = unknown> implements GuestAwareType<T> {
|
81
67
|
private guestReceiver;
|
82
68
|
constructor(guestReceiver: (guest: GuestType<T>) => void);
|
83
69
|
receiving(guest: GuestType<T>): GuestType<T>;
|
84
70
|
}
|
85
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;
|
79
|
+
}
|
80
|
+
|
86
81
|
declare class GuestCast<T> implements GuestType<T> {
|
87
82
|
private sourceGuest;
|
88
83
|
private targetGuest;
|
@@ -99,12 +94,6 @@ declare class GuestInTheMiddle<T> implements GuestType<T> {
|
|
99
94
|
receive(value: T, options?: ReceiveOptions): this;
|
100
95
|
}
|
101
96
|
|
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
97
|
declare class GuestPool<T> implements GuestType<T>, PoolType<T> {
|
109
98
|
private guests;
|
110
99
|
private patronPool;
|
@@ -116,21 +105,20 @@ declare class GuestPool<T> implements GuestType<T>, PoolType<T> {
|
|
116
105
|
private deliverToGuests;
|
117
106
|
}
|
118
107
|
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
value(): T;
|
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>;
|
128
116
|
}
|
129
117
|
|
130
118
|
/**
|
131
119
|
* Патрон - это постоянный посетитель
|
132
120
|
*/
|
133
|
-
declare class
|
121
|
+
declare class PatronOfGuest<T> implements GuestType<T> {
|
134
122
|
private willBePatron;
|
135
123
|
constructor(willBePatron: GuestType<T>);
|
136
124
|
introduction(): "patron";
|
@@ -145,29 +133,17 @@ declare class PatronOnce<T> implements GuestType<T> {
|
|
145
133
|
receive(value: T, options?: ReceiveOptions): this;
|
146
134
|
}
|
147
135
|
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
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;
|
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>;
|
161
140
|
}
|
162
141
|
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
constructor(sourceDocument: T);
|
169
|
-
receive(value: T): this;
|
170
|
-
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
|
+
};
|
171
147
|
}
|
172
148
|
|
173
|
-
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
|