patron-oop 1.6.0 → 1.7.0
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +9 -0
- package/dist/patron.d.ts +61 -80
- package/dist/patron.js +75 -110
- package/dist/patron.js.map +1 -1
- package/dist/patron.min.js +1 -1
- package/dist/patron.mjs +70 -109
- package/dist/patron.mjs.map +1 -1
- package/package.json +1 -1
- package/src/Guest/Guest.test.ts +10 -0
- package/src/Guest/Guest.ts +28 -35
- package/src/Guest/GuestAware.test.ts +6 -8
- package/src/Guest/GuestAware.ts +1 -1
- package/src/Guest/GuestCast.test.ts +6 -6
- package/src/Guest/GuestCast.ts +7 -3
- package/src/Guest/GuestChain.test.ts +12 -12
- package/src/Guest/GuestChain.ts +11 -11
- package/src/Guest/GuestInTheMiddle.test.ts +9 -9
- package/src/Guest/GuestInTheMiddle.ts +3 -3
- package/src/Guest/GuestPool.test.ts +10 -17
- package/src/Guest/GuestPool.ts +10 -6
- package/src/Guest/GuestSync.test.ts +2 -2
- package/src/Guest/GuestSync.ts +2 -2
- package/src/Patron/{PatronOfGuest.test.ts → Patron.test.ts} +4 -7
- package/src/Patron/Patron.ts +16 -12
- package/src/Patron/PatronOnce.test.ts +3 -6
- package/src/Patron/PatronOnce.ts +8 -3
- package/src/Patron/PatronPool.test.ts +9 -14
- package/src/Patron/PatronPool.ts +16 -10
- package/src/Source/SourceOfValue.test.ts +3 -6
- package/src/Source/SourceOfValue.ts +7 -3
- package/src/index.ts +35 -13
- package/src/Guest/GuestCallback.test.ts +0 -13
- package/src/Guest/GuestCallback.ts +0 -21
- package/src/Patron/PatronOfGuest.ts +0 -17
- package/src/Source/Source.ts +0 -12
- package/src/Source/SourcesApplied.test.ts +0 -26
- package/src/Source/SourcesApplied.ts +0 -39
@@ -1,39 +0,0 @@
|
|
1
|
-
type TupleSplit<
|
2
|
-
T,
|
3
|
-
N extends number,
|
4
|
-
O extends readonly any[] = readonly [],
|
5
|
-
> = O["length"] extends N
|
6
|
-
? [O, T]
|
7
|
-
: T extends readonly [infer F, ...infer R]
|
8
|
-
? TupleSplit<readonly [...R], N, readonly [...O, F]>
|
9
|
-
: [O, T];
|
10
|
-
|
11
|
-
type SkipFirst<T extends readonly any[], N extends number> = TupleSplit<
|
12
|
-
T,
|
13
|
-
N
|
14
|
-
>[1];
|
15
|
-
|
16
|
-
export const sourcesApplied = <T>(
|
17
|
-
target: T,
|
18
|
-
methodsSources: Record<string, unknown[]>,
|
19
|
-
) => {
|
20
|
-
return new Proxy(target as object, {
|
21
|
-
get: function (target: any, property) {
|
22
|
-
const maybeMethod = target[property];
|
23
|
-
|
24
|
-
if (typeof maybeMethod !== "function") {
|
25
|
-
return maybeMethod;
|
26
|
-
}
|
27
|
-
|
28
|
-
return (...args: any[]) => {
|
29
|
-
const appliedArgs = (methodsSources as any)[property];
|
30
|
-
|
31
|
-
if (appliedArgs) {
|
32
|
-
return maybeMethod(...appliedArgs, ...args);
|
33
|
-
}
|
34
|
-
|
35
|
-
return maybeMethod(...args);
|
36
|
-
};
|
37
|
-
},
|
38
|
-
});
|
39
|
-
};
|