patron-oop 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/LICENSE.md +7 -0
  3. package/README.md +9 -0
  4. package/commitizen.cjs +50 -0
  5. package/dist/patron.d.ts +173 -0
  6. package/dist/patron.js +363 -0
  7. package/dist/patron.js.map +1 -0
  8. package/dist/patron.mjs +346 -0
  9. package/dist/patron.mjs.map +1 -0
  10. package/eslint.config.mjs +36 -0
  11. package/package.json +48 -0
  12. package/rollup.config.js +35 -0
  13. package/src/Cache.test.ts +20 -0
  14. package/src/Cache.ts +31 -0
  15. package/src/CacheType.ts +4 -0
  16. package/src/Chain.test.ts +72 -0
  17. package/src/Chain.ts +79 -0
  18. package/src/ChainType.ts +7 -0
  19. package/src/Factory.test.ts +16 -0
  20. package/src/Factory.ts +21 -0
  21. package/src/FactoryDynamic.ts +11 -0
  22. package/src/FactoryType.ts +3 -0
  23. package/src/FactoryWithFactories.ts +25 -0
  24. package/src/Guest.test.ts +13 -0
  25. package/src/Guest.ts +11 -0
  26. package/src/GuestAware.ts +11 -0
  27. package/src/GuestAwareType.ts +5 -0
  28. package/src/GuestCast.ts +20 -0
  29. package/src/GuestExecutorType.ts +3 -0
  30. package/src/GuestInTheMiddle.test.ts +71 -0
  31. package/src/GuestInTheMiddle.ts +20 -0
  32. package/src/GuestPool.test.ts +41 -0
  33. package/src/GuestPool.ts +46 -0
  34. package/src/GuestSync.test.ts +11 -0
  35. package/src/GuestSync.ts +14 -0
  36. package/src/GuestType.ts +10 -0
  37. package/src/GuestValueType.ts +5 -0
  38. package/src/Patron.test.ts +20 -0
  39. package/src/Patron.ts +17 -0
  40. package/src/PatronOnce.test.ts +18 -0
  41. package/src/PatronOnce.ts +30 -0
  42. package/src/PatronPool.test.ts +26 -0
  43. package/src/PatronPool.ts +76 -0
  44. package/src/PoolType.ts +7 -0
  45. package/src/Source.test.ts +13 -0
  46. package/src/Source.ts +20 -0
  47. package/src/SourceType.ts +4 -0
  48. package/src/index.ts +16 -0
  49. 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
+ }
@@ -0,0 +1,4 @@
1
+ import { GuestAwareType } from "./GuestAwareType";
2
+ import { GuestType } from "./GuestType";
3
+
4
+ export type SourceType<T = unknown> = GuestAwareType<T> & GuestType<T>;
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
+ }