udic 0.0.2 → 0.0.3

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.
Files changed (3) hide show
  1. package/README.md +6 -6
  2. package/di.d.ts +4 -0
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -1,12 +1,11 @@
1
- ## DEI
2
- A simple dependency injection library
1
+ A simple dependency injection library.
3
2
  ```ts
4
- import { di } from "udic";
3
+ import { di } from 'udic';
5
4
 
6
- const rand = di.service("rand")<number>();
5
+ const rand = di.service('rand')<number>();
7
6
  const computed = di.compute((val) => val + 1, rand);
8
7
 
9
- const rand1 = di.service("rand1")<number>();
8
+ const rand1 = di.service('rand1')<number>();
10
9
  const computed1 = di.compute(
11
10
  (val, computed0) => val + computed0,
12
11
  rand1,
@@ -19,5 +18,6 @@ console.log(
19
18
  rand1: 9,
20
19
  }),
21
20
  );
22
-
23
21
  ```
22
+
23
+ This should only be used to replace singletons.
package/di.d.ts CHANGED
@@ -1,9 +1,11 @@
1
+ declare const tag: unique symbol;
1
2
  export interface Service<
2
3
  T extends string | symbol,
3
4
  K
4
5
  > {
5
6
  0: K;
6
7
  1: K extends undefined ? { [k in T]? : K } : { [k in T] : K };
8
+ readonly [tag]: null;
7
9
  }
8
10
  export interface Compute<
9
11
  T extends Dependency[],
@@ -12,6 +14,7 @@ export interface Compute<
12
14
  (args: InferDependenciesRecord<T>): R;
13
15
  0: R;
14
16
  1: InferDependenciesRecord<T>;
17
+ readonly [tag]: null;
15
18
  }
16
19
  export type AnyService = Service<string | symbol, any>;
17
20
  export type AnyCompute = Compute<any[], any>;
@@ -23,3 +26,4 @@ export declare const compute: <
23
26
  const T extends Dependency[],
24
27
  const R
25
28
  >(f: (...args: InferDependencies<NoInfer<T>>) => R, ...deps: T) => Compute<T, R>;
29
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "udic",
3
- "version": "0.0.2",
3
+ "version": "0.0.3",
4
4
  "description": "A simple dependency injection library",
5
5
  "keywords": [],
6
6
  "license": "MIT",