udic 2.0.3 → 2.0.4

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/index.d.ts +8 -12
  2. package/index.js +1 -1
  3. package/package.json +1 -1
package/index.d.ts CHANGED
@@ -4,8 +4,6 @@ export type ContextArgs = {
4
4
  } | ((...args: any[]) => any);
5
5
  export type Context<Deps extends ContextArgs> = ObjectUnionToIntersect<Deps extends (() => infer Out extends {}) ? Awaited<Out> : Deps extends ((c: infer In extends {}) => infer Out extends {}) ? In & Awaited<Out> : Deps extends (c: infer C, ...args: any[]) => any ? C : Deps>;
6
6
  export interface Impl {
7
- <const F extends () => {}>(fn: F): F;
8
- <const F extends (c: any) => {}>(fn: F): F;
9
7
  <const Out extends ContextArgs>(fn: (c: {}) => Context<Out>): (c: {}) => Context<Out>;
10
8
  <
11
9
  const In extends ContextArgs,
@@ -17,8 +15,6 @@ export interface Impl {
17
15
  */
18
16
  export declare const impl: Impl;
19
17
  export interface ImplAsync {
20
- <const F extends () => {} | Promise<{}>>(fn: F): F;
21
- <const F extends (c: any) => {} | Promise<{}>>(fn: F): F;
22
18
  <const Out extends ContextArgs>(fn: (c: {}) => Context<Out> | Promise<Context<Out>>): (c: {}) => Context<Out> | Promise<Context<Out>>;
23
19
  <
24
20
  const In extends ContextArgs,
@@ -31,18 +27,18 @@ export interface ImplAsync {
31
27
  export declare const implAsync: ImplAsync;
32
28
  type _ImplFn = (() => {} | Promise<{}>) | ((c: any) => {} | Promise<{}>);
33
29
  type _ImplFns = [_ImplFn, ..._ImplFn[]];
30
+ interface Link {
31
+ <
32
+ const In extends {},
33
+ Impls extends _ImplFns
34
+ >(c: In, ...impls: Impls): Context<Impls[number]>;
35
+ }
34
36
  /**
35
37
  * Link sync implementations.
36
38
  */
37
- export declare const link: <
38
- const In extends {},
39
- Impls extends _ImplFns
40
- >(c: In, ...impls: Impls) => In & ReturnType<Impls[number]>;
39
+ export declare const link: Link;
41
40
  /**
42
41
  * Link async implementations concurrently.
43
42
  */
44
- export declare const linkAsync: <
45
- const In extends {},
46
- Impls extends _ImplFns
47
- >(c: In, ...impls: Impls) => Promise<In & Awaited<ReturnType<Impls[number]>>>;
43
+ export declare const linkAsync: Link;
48
44
  export {};
package/index.js CHANGED
@@ -1 +1 @@
1
- export let impl=e=>e;export let implAsync=e=>e;export let link=(e,t,...n)=>{e=Object.assign(t(e),e);for(let t=0;t<n.length;t++)Object.assign(e,n[t](e));return e};export let linkAsync=async(e,...t)=>{if(t.length===1)return Object.assign(await t[0](e),e);let n=Array(t.length);for(let r=0;r<t.length;r++)n[r]=t[r](e);return Object.assign(...await Promise.all(n),e)};
1
+ export let impl=e=>e;export let implAsync=e=>e;export let link=(e,...t)=>{for(let n=0;n<t.length;n++)Object.assign(e,t[n](e));return e};export let linkAsync=async(e,...t)=>{if(t.length===1)return Object.assign(e,await t[0](e));let n=Array(t.length);for(let r=0;r<t.length;r++)n[r]=t[r](e);return Object.assign(e,...await Promise.all(n))};
package/package.json CHANGED
@@ -1 +1 @@
1
- {"name":"udic","version":"2.0.3","description":"A simple dependency injection library","keywords":["di"],"license":"MIT","homepage":"https://re-utils.pages.dev/di","repository":{"type":"git","url":"git+https://github.com/re-utils/di.git"},"type":"module","main":"./index.js","types":"./index.d.ts","exports":{".":"./index.js"}}
1
+ {"name":"udic","version":"2.0.4","description":"A simple dependency injection library","keywords":["di"],"license":"MIT","homepage":"https://re-utils.pages.dev/di","repository":{"type":"git","url":"git+https://github.com/re-utils/di.git"},"type":"module","main":"./index.js","types":"./index.d.ts","exports":{".":"./index.js"}}