patron-oop 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +11 -0
- package/LICENSE.md +7 -0
- package/README.md +9 -0
- package/commitizen.cjs +50 -0
- package/dist/patron.d.ts +173 -0
- package/dist/patron.js +363 -0
- package/dist/patron.js.map +1 -0
- package/dist/patron.mjs +346 -0
- package/dist/patron.mjs.map +1 -0
- package/eslint.config.mjs +36 -0
- package/package.json +48 -0
- package/rollup.config.js +35 -0
- package/src/Cache.test.ts +20 -0
- package/src/Cache.ts +31 -0
- package/src/CacheType.ts +4 -0
- package/src/Chain.test.ts +72 -0
- package/src/Chain.ts +79 -0
- package/src/ChainType.ts +7 -0
- package/src/Factory.test.ts +16 -0
- package/src/Factory.ts +21 -0
- package/src/FactoryDynamic.ts +11 -0
- package/src/FactoryType.ts +3 -0
- package/src/FactoryWithFactories.ts +25 -0
- package/src/Guest.test.ts +13 -0
- package/src/Guest.ts +11 -0
- package/src/GuestAware.ts +11 -0
- package/src/GuestAwareType.ts +5 -0
- package/src/GuestCast.ts +20 -0
- package/src/GuestExecutorType.ts +3 -0
- package/src/GuestInTheMiddle.test.ts +71 -0
- package/src/GuestInTheMiddle.ts +20 -0
- package/src/GuestPool.test.ts +41 -0
- package/src/GuestPool.ts +46 -0
- package/src/GuestSync.test.ts +11 -0
- package/src/GuestSync.ts +14 -0
- package/src/GuestType.ts +10 -0
- package/src/GuestValueType.ts +5 -0
- package/src/Patron.test.ts +20 -0
- package/src/Patron.ts +17 -0
- package/src/PatronOnce.test.ts +18 -0
- package/src/PatronOnce.ts +30 -0
- package/src/PatronPool.test.ts +26 -0
- package/src/PatronPool.ts +76 -0
- package/src/PoolType.ts +7 -0
- package/src/Source.test.ts +13 -0
- package/src/Source.ts +20 -0
- package/src/SourceType.ts +4 -0
- package/src/index.ts +16 -0
- package/tsconfig.json +26 -0
@@ -0,0 +1,13 @@
|
|
1
|
+
import { expect, test } from "vitest";
|
2
|
+
import { Source } from "./Source";
|
3
|
+
import { Guest } from "./Guest";
|
4
|
+
|
5
|
+
test("source", () => {
|
6
|
+
const source = new Source(42);
|
7
|
+
|
8
|
+
source.receiving(
|
9
|
+
new Guest((value) => {
|
10
|
+
expect(value).toBe(42);
|
11
|
+
}),
|
12
|
+
);
|
13
|
+
});
|
package/src/Source.ts
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
import { GuestType } from "./GuestType";
|
2
|
+
import { PatronPool } from "./PatronPool";
|
3
|
+
import { SourceType } from "./SourceType";
|
4
|
+
|
5
|
+
export class Source<T> implements SourceType<T> {
|
6
|
+
private pool = new PatronPool(this);
|
7
|
+
|
8
|
+
public constructor(private sourceDocument: T) {}
|
9
|
+
|
10
|
+
public receive(value: T): this {
|
11
|
+
this.sourceDocument = value;
|
12
|
+
this.pool.receive(this.sourceDocument);
|
13
|
+
return this;
|
14
|
+
}
|
15
|
+
|
16
|
+
public receiving(guest: GuestType<T>): this {
|
17
|
+
this.pool.distribute(this.sourceDocument, guest);
|
18
|
+
return this;
|
19
|
+
}
|
20
|
+
}
|
package/src/index.ts
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
export * from "./Cache";
|
2
|
+
export * from "./Chain";
|
3
|
+
export * from "./Factory";
|
4
|
+
export * from "./FactoryDynamic";
|
5
|
+
export * from "./FactoryType";
|
6
|
+
export * from "./FactoryWithFactories";
|
7
|
+
export * from "./Guest";
|
8
|
+
export * from "./GuestAware";
|
9
|
+
export * from "./GuestCast";
|
10
|
+
export * from "./GuestInTheMiddle";
|
11
|
+
export * from "./GuestPool";
|
12
|
+
export * from "./GuestSync";
|
13
|
+
export * from "./Patron";
|
14
|
+
export * from "./PatronOnce";
|
15
|
+
export * from "./PatronPool";
|
16
|
+
export * from "./Source";
|
package/tsconfig.json
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
{
|
2
|
+
"compilerOptions": {
|
3
|
+
"target": "esnext",
|
4
|
+
"module": "esnext",
|
5
|
+
"strict": true,
|
6
|
+
"moduleResolution": "node",
|
7
|
+
"skipLibCheck": true,
|
8
|
+
"esModuleInterop": true,
|
9
|
+
"allowSyntheticDefaultImports": true,
|
10
|
+
"forceConsistentCasingInFileNames": true,
|
11
|
+
"useDefineForClassFields": true,
|
12
|
+
"sourceMap": true,
|
13
|
+
"baseUrl": ".",
|
14
|
+
"resolveJsonModule": true,
|
15
|
+
"lib": [
|
16
|
+
"es2022",
|
17
|
+
"dom"
|
18
|
+
]
|
19
|
+
},
|
20
|
+
"include": [
|
21
|
+
"src/**/*.ts",
|
22
|
+
],
|
23
|
+
"exclude": [
|
24
|
+
"node_modules"
|
25
|
+
]
|
26
|
+
}
|