Skip to content

Commit e5bb120

Browse files
committed
feat(utils): Export utility type to unwrap lazy values
1 parent 69c300f commit e5bb120

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

.changeset/many-humans-trade.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@inox-tools/utils': patch
3+
---
4+
5+
Export utility type `UnwrapLazies` to turn an array of `Lazy` instances into an array of their lazy values.

packages/utils/src/lazy.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ type LazyMapping<T, O = void> = (name: string, value: T) => O;
1111
*
1212
* @template T - A tuple of Lazy instances
1313
*/
14-
type UnwrapLazies<T extends Lazy<any>[]> = T extends [
14+
export type UnwrapLazies<T extends Lazy<any>[]> = T extends [
1515
Lazy<infer First>,
1616
...infer Rest extends Lazy<any>[],
1717
]
@@ -45,7 +45,7 @@ export class Lazy<T> implements Promise<T> {
4545

4646
private attachments?: ((value: T) => void)[] = [];
4747

48-
private constructor(private factory: () => T) {}
48+
private constructor(private factory: () => T) { }
4949

5050
/**
5151
* Creates a new Lazy instance from a factory function.
@@ -264,7 +264,7 @@ export class LazyKeyed<T> {
264264
/** List of callbacks to invoke when any value is created */
265265
private readonly attachments: LazyMapping<T>[] = [];
266266

267-
private constructor(private factory: (key: string) => T) {}
267+
private constructor(private factory: (key: string) => T) { }
268268

269269
/**
270270
* Creates a new LazyKeyed instance from a factory function.

0 commit comments

Comments
 (0)