@tstdl/base 0.83.27 → 0.84.0

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 (55) hide show
  1. package/application/application.d.ts +1 -1
  2. package/application/application.js +4 -4
  3. package/browser/browser-context-controller.d.ts +32 -0
  4. package/browser/browser-context-controller.js +88 -0
  5. package/browser/browser-controller.d.ts +45 -0
  6. package/browser/browser-controller.js +109 -0
  7. package/browser/browser.service.d.ts +34 -0
  8. package/browser/browser.service.js +107 -0
  9. package/browser/index.d.ts +4 -0
  10. package/browser/index.js +21 -0
  11. package/browser/page-controller.d.ts +54 -0
  12. package/browser/page-controller.js +166 -0
  13. package/browser/pdf-options.d.ts +36 -0
  14. package/browser/pdf-options.js +138 -0
  15. package/browser/utils.d.ts +6 -0
  16. package/browser/utils.js +60 -0
  17. package/core.d.ts +1 -1
  18. package/data-structures/cache.d.ts +11 -0
  19. package/data-structures/cache.js +69 -0
  20. package/data-structures/index.d.ts +1 -0
  21. package/data-structures/index.js +1 -0
  22. package/disposable/async-disposer.d.ts +2 -1
  23. package/error/index.d.ts +1 -0
  24. package/error/index.js +1 -0
  25. package/error/timeout.error.d.ts +5 -0
  26. package/error/timeout.error.js +30 -0
  27. package/examples/browser/basic.d.ts +1 -0
  28. package/examples/browser/basic.js +19 -0
  29. package/examples/mail/basic.js +11 -3
  30. package/examples/pdf/basic.js +33 -7
  31. package/examples/pdf/templates/hello-name.js +10 -2
  32. package/http/client/http-client-request.js +1 -1
  33. package/http/server/node/node-http-server.js +1 -1
  34. package/lock/web/web-lock.js +2 -2
  35. package/package.json +6 -6
  36. package/pdf/pdf.service.d.ts +23 -58
  37. package/pdf/pdf.service.js +33 -203
  38. package/pool/pool.d.ts +1 -0
  39. package/pool/pool.js +6 -0
  40. package/queue/mongo/queue.js +2 -2
  41. package/types.d.ts +3 -0
  42. package/utils/cancellation-token.d.ts +11 -16
  43. package/utils/cancellation-token.js +10 -39
  44. package/utils/index.d.ts +1 -0
  45. package/utils/index.js +1 -0
  46. package/utils/stream/finalize-stream.d.ts +22 -1
  47. package/utils/stream/finalize-stream.js +14 -4
  48. package/utils/stream/readable-stream-from-promise.d.ts +2 -1
  49. package/utils/stream/readable-stream-from-promise.js +3 -2
  50. package/utils/timing.d.ts +7 -1
  51. package/utils/timing.js +23 -3
  52. package/utils/type-guards.d.ts +6 -0
  53. package/utils/type-guards.js +26 -0
  54. package/utils/value-or-provider.d.ts +2 -0
  55. package/utils/value-or-provider.js +30 -0
@@ -216,7 +216,7 @@ let MongoQueue = class MongoQueue2 extends import_queue.Queue {
216
216
  return this.cancelMany(jobIds);
217
217
  }
218
218
  async *getConsumer(cancellationToken) {
219
- const continueToken = import_cancellation_token.CancellationToken.fromObservable(this.messageBus.allMessages$);
219
+ const continueToken = import_cancellation_token.CancellationToken.from(this.messageBus.allMessages$);
220
220
  for await (const backoff of (0, import_backoff.backoffGenerator)(backoffOptions, cancellationToken)) {
221
221
  const job = await this.dequeue();
222
222
  if (job != void 0) {
@@ -228,7 +228,7 @@ let MongoQueue = class MongoQueue2 extends import_queue.Queue {
228
228
  continueToken.complete();
229
229
  }
230
230
  async *getBatchConsumer(size, cancellationToken) {
231
- const continueToken = import_cancellation_token.CancellationToken.fromObservable(this.messageBus.allMessages$);
231
+ const continueToken = import_cancellation_token.CancellationToken.from(this.messageBus.allMessages$);
232
232
  for await (const backoff of (0, import_backoff.backoffGenerator)(backoffOptions, cancellationToken)) {
233
233
  const jobs = await this.dequeueMany(size);
234
234
  if (jobs.length > 0) {
package/types.d.ts CHANGED
@@ -112,6 +112,9 @@ export type OmitBy<T, V> = Omit<T, {
112
112
  * normalize properties of a type that allow `undefined` to make them optional.
113
113
  */
114
114
  export type Optionalize<T extends object> = OmitBy<T, undefined> & Partial<PickBy<T, undefined>>;
115
+ export type Unoptionalize<T extends object> = Simplify<OmitBy<T, undefined> & {
116
+ [P in PropertiesOfType<T, undefined>]: T[P] | undefined;
117
+ }>;
115
118
  export type SimplifiedOptionalize<T extends object> = Simplify<Optionalize<T>>;
116
119
  export type Merge<T1, T2> = SimplifyObject<Except<T1, Extract<keyof T1, keyof T2>> & T2>;
117
120
  export type Simplify<T> = T extends BuiltIn ? T : T extends readonly any[] ? SimplifyArray<T> : T extends Record ? SimplifyObject<T> : T;
@@ -67,7 +67,7 @@ export interface ReadonlyCancellationToken extends PromiseLike<void>, Subscribab
67
67
  /**
68
68
  * Returns an AbortSignal.
69
69
  */
70
- asAbortSignal: AbortSignal;
70
+ asAbortSignal(): AbortSignal;
71
71
  /**
72
72
  * Create a new token and connect it to this instance.
73
73
  * @see {@link connect}
@@ -81,7 +81,6 @@ export interface ReadonlyCancellationToken extends PromiseLike<void>, Subscribab
81
81
  }
82
82
  export declare class CancellationToken implements ReadonlyCancellationToken {
83
83
  private readonly stateSubject;
84
- private abortController;
85
84
  readonly state$: Observable<boolean>;
86
85
  readonly set$: Observable<void>;
87
86
  readonly unset$: Observable<void>;
@@ -90,8 +89,6 @@ export declare class CancellationToken implements ReadonlyCancellationToken {
90
89
  get $set(): Promise<void>;
91
90
  get $unset(): Promise<void>;
92
91
  get $state(): Promise<boolean>;
93
- get asReadonly(): ReadonlyCancellationToken;
94
- get asAbortSignal(): AbortSignal;
95
92
  /**
96
93
  * @param initialState which state to initialze this token to
97
94
  * - `false`: unset
@@ -100,23 +97,21 @@ export declare class CancellationToken implements ReadonlyCancellationToken {
100
97
  */
101
98
  constructor(initialState?: boolean);
102
99
  /**
103
- * Creates a token and sets it whenever the abort signal is aborted.
104
- * @param signal abort signal to listen to
105
- * @param complete complete token after resolve
100
+ * Creates a token and sets it whenever the source signals
101
+ * @param source source to listen to
102
+ * @param complete complete token after signal
106
103
  */
107
- static fromAbortSignal(signal: AbortSignal, complete?: boolean): CancellationToken;
104
+ static from(source: AbortSignal | PromiseLike<any> | Observable<void>, options?: {
105
+ complete?: boolean;
106
+ }): CancellationToken;
108
107
  /**
109
- * Creates a token and sets it whenever the promise is resolved.
110
- * @param promise promise to await
111
- * @param complete complete token after resolve
112
- */
113
- static fromPromise(promise: PromiseLike<any>, complete?: boolean): CancellationToken;
114
- /**
115
- * Creates a token and connets its next, error and complete.
108
+ * Creates a token and connects the source to its next, error and complete.
116
109
  * @param observable observable to subscribe. Takes emitted value as state if type is boolean otherwise sets state to true.
117
110
  */
118
- static fromObservable(observable: Observable<void | boolean>, config?: ConnectConfig): CancellationToken;
111
+ static from(source: Observable<boolean>, config?: ConnectConfig): CancellationToken;
119
112
  private static connect;
113
+ asAbortSignal(): AbortSignal;
114
+ asReadonly(): ReadonlyCancellationToken;
120
115
  createChild(config?: ConnectConfig): CancellationToken;
121
116
  connect(child: CancellationToken, config?: ConnectConfig): void;
122
117
  /**
@@ -27,7 +27,6 @@ var import_noop2 = require("./noop.js");
27
27
  var import_type_guards = require("./type-guards.js");
28
28
  class CancellationToken {
29
29
  stateSubject;
30
- abortController;
31
30
  state$;
32
31
  set$;
33
32
  unset$;
@@ -46,20 +45,6 @@ class CancellationToken {
46
45
  get $state() {
47
46
  return (0, import_rxjs.firstValueFrom)(this.state$.pipe((0, import_rxjs.skip)(1)));
48
47
  }
49
- get asReadonly() {
50
- return this;
51
- }
52
- get asAbortSignal() {
53
- if ((0, import_type_guards.isUndefined)(this.abortController)) {
54
- const abortController = new AbortController();
55
- this.abortController = abortController;
56
- this.set$.pipe((0, import_rxjs.first)()).subscribe(() => {
57
- abortController.abort();
58
- this.unset$.pipe((0, import_rxjs.first)()).subscribe(() => this.abortController = void 0);
59
- });
60
- }
61
- return this.abortController.signal;
62
- }
63
48
  /**
64
49
  * @param initialState which state to initialze this token to
65
50
  * - `false`: unset
@@ -72,31 +57,9 @@ class CancellationToken {
72
57
  this.set$ = this.state$.pipe((0, import_rxjs.filter)((state) => state), (0, import_rxjs.map)(() => void 0));
73
58
  this.unset$ = this.state$.pipe((0, import_rxjs.filter)((state) => !state), (0, import_rxjs.map)(() => void 0));
74
59
  }
75
- /**
76
- * Creates a token and sets it whenever the abort signal is aborted.
77
- * @param signal abort signal to listen to
78
- * @param complete complete token after resolve
79
- */
80
- static fromAbortSignal(signal, complete = true) {
81
- const signal$ = (0, import_rxjs.fromEvent)(signal, "abort", () => true);
82
- return CancellationToken.fromObservable(signal$, { complete });
83
- }
84
- /**
85
- * Creates a token and sets it whenever the promise is resolved.
86
- * @param promise promise to await
87
- * @param complete complete token after resolve
88
- */
89
- static fromPromise(promise, complete = true) {
90
- const signal$ = (0, import_rxjs.from)(promise).pipe((0, import_rxjs.map)(() => true));
91
- return CancellationToken.fromObservable(signal$, { complete });
92
- }
93
- /**
94
- * Creates a token and connets its next, error and complete.
95
- * @param observable observable to subscribe. Takes emitted value as state if type is boolean otherwise sets state to true.
96
- */
97
- static fromObservable(observable, config) {
60
+ static from(source, config) {
61
+ const source$ = source instanceof AbortSignal ? (0, import_rxjs.fromEvent)(source, "abort", () => true) : (0, import_rxjs.isObservable)(source) ? source.pipe((0, import_rxjs.map)((state) => (0, import_type_guards.isBoolean)(state) ? state : true)) : (0, import_rxjs.from)(source).pipe((0, import_rxjs.map)(() => true));
98
62
  const token = new CancellationToken();
99
- const source$ = observable.pipe((0, import_rxjs.map)((state) => (0, import_type_guards.isBoolean)(state) ? state : true));
100
63
  CancellationToken.connect(source$, token, config);
101
64
  return token;
102
65
  }
@@ -113,6 +76,14 @@ class CancellationToken {
113
76
  complete: () => subscription.unsubscribe()
114
77
  });
115
78
  }
79
+ asAbortSignal() {
80
+ const abortController = new AbortController();
81
+ this.set$.pipe((0, import_rxjs.first)()).subscribe(() => abortController.abort());
82
+ return abortController.signal;
83
+ }
84
+ asReadonly() {
85
+ return this;
86
+ }
116
87
  createChild(config) {
117
88
  const child = new CancellationToken();
118
89
  this.connect(child, config);
package/utils/index.d.ts CHANGED
@@ -44,4 +44,5 @@ export * from './type-guards.js';
44
44
  export * from './type-of.js';
45
45
  export * from './units.js';
46
46
  export * from './url-builder.js';
47
+ export * from './value-or-provider.js';
47
48
  export * from './z-base32.js';
package/utils/index.js CHANGED
@@ -61,4 +61,5 @@ __reExport(utils_exports, require("./type-guards.js"), module.exports);
61
61
  __reExport(utils_exports, require("./type-of.js"), module.exports);
62
62
  __reExport(utils_exports, require("./units.js"), module.exports);
63
63
  __reExport(utils_exports, require("./url-builder.js"), module.exports);
64
+ __reExport(utils_exports, require("./value-or-provider.js"), module.exports);
64
65
  __reExport(utils_exports, require("./z-base32.js"), module.exports);
@@ -1 +1,22 @@
1
- export declare function finalizeStream<T>(stream: ReadableStream<T>, finalizer: () => void | PromiseLike<void>): ReadableStream<T>;
1
+ export type ReadableStreamFinalizeEvent = {
2
+ type: 'done';
3
+ } | {
4
+ type: 'error';
5
+ error: any;
6
+ } | {
7
+ type: 'cancel';
8
+ reason: any;
9
+ };
10
+ /**
11
+ * Finalizer is called *after* the specific event occurred.
12
+ */
13
+ export type StreamFinalizerHandler = (event: ReadableStreamFinalizeEvent) => void | Promise<void>;
14
+ export type FinalizeStreamHandlers = {
15
+ finalizer?: StreamFinalizerHandler;
16
+ beforeDone?: () => void | Promise<void>;
17
+ done?: () => void | Promise<void>;
18
+ error?: (error: Error) => void | Promise<void>;
19
+ beforeCancel?: (reason: any) => void | Promise<void>;
20
+ cancel?: (reason: any) => void | Promise<void>;
21
+ };
22
+ export declare function finalizeStream<T>(stream: ReadableStream<T>, finalizerOrHandlers: StreamFinalizerHandler | FinalizeStreamHandlers): ReadableStream<T>;
@@ -21,7 +21,9 @@ __export(finalize_stream_exports, {
21
21
  finalizeStream: () => finalizeStream
22
22
  });
23
23
  module.exports = __toCommonJS(finalize_stream_exports);
24
- function finalizeStream(stream, finalizer) {
24
+ var import_type_guards = require("../type-guards.js");
25
+ function finalizeStream(stream, finalizerOrHandlers) {
26
+ const handlers = (0, import_type_guards.isFunction)(finalizerOrHandlers) ? { finalizer: finalizerOrHandlers } : finalizerOrHandlers;
25
27
  let reader;
26
28
  return new ReadableStream({
27
29
  start() {
@@ -32,21 +34,29 @@ function finalizeStream(stream, finalizer) {
32
34
  try {
33
35
  chunk = await reader.read();
34
36
  } catch (error) {
35
- await finalizer();
37
+ await handlers.error?.(error);
38
+ await handlers.finalizer?.({ type: "error", error });
36
39
  throw error;
37
40
  }
38
41
  if (chunk.done) {
42
+ await handlers.beforeDone?.();
39
43
  controller.close();
40
- await finalizer();
44
+ await handlers.done?.();
45
+ await handlers.finalizer?.({ type: "done" });
41
46
  } else {
42
47
  controller.enqueue(chunk.value);
43
48
  }
44
49
  },
45
50
  async cancel(reason) {
46
51
  try {
52
+ await handlers.beforeCancel?.(reason);
47
53
  await reader.cancel(reason);
54
+ await handlers.cancel?.(reason);
55
+ } catch (error) {
56
+ await handlers.error?.(error);
57
+ throw error;
48
58
  } finally {
49
- await finalizer();
59
+ await handlers.finalizer?.({ type: "cancel", reason });
50
60
  }
51
61
  }
52
62
  });
@@ -1 +1,2 @@
1
- export declare function readableStreamFromPromise<T>(executor: () => Promise<ReadableStream<T>>): ReadableStream<T>;
1
+ import type { ValueOrProvider } from '../value-or-provider.js';
2
+ export declare function readableStreamFromPromise<T>(promiseOrProvider: ValueOrProvider<Promise<ReadableStream<T>>>): ReadableStream<T>;
@@ -21,8 +21,9 @@ __export(readable_stream_from_promise_exports, {
21
21
  readableStreamFromPromise: () => readableStreamFromPromise
22
22
  });
23
23
  module.exports = __toCommonJS(readable_stream_from_promise_exports);
24
- function readableStreamFromPromise(executor) {
24
+ var import_value_or_provider = require("../value-or-provider.js");
25
+ function readableStreamFromPromise(promiseOrProvider) {
25
26
  const stream = new TransformStream();
26
- executor().then(async (readable) => readable.pipeTo(stream.writable)).catch(async (error) => stream.writable.abort(error));
27
+ (0, import_value_or_provider.resolveValueOrProvider)(promiseOrProvider).then(async (readable) => readable.pipeTo(stream.writable)).catch(async (error) => stream.writable.abort(error));
27
28
  return stream.readable;
28
29
  }
package/utils/timing.d.ts CHANGED
@@ -1,12 +1,18 @@
1
1
  import type { ReadonlyCancellationToken } from './cancellation-token.js';
2
+ import type { ValueOrProvider } from './value-or-provider.js';
2
3
  /** timeout for specified duration */
3
- export declare function timeout(milliseconds?: number): Promise<void>;
4
+ export declare function timeout(milliseconds?: number, options?: {
5
+ abortSignal?: AbortSignal;
6
+ }): Promise<void>;
4
7
  /** timeout until specified time */
5
8
  export declare function timeoutUntil(timestamp: number | Date): Promise<void>;
6
9
  /** timeout for specified duration */
7
10
  export declare function cancelableTimeout(milliseconds: number, cancelToken: ReadonlyCancellationToken): Promise<boolean>;
8
11
  /** timeout until specified time */
9
12
  export declare function cancelableTimeoutUntil(timestamp: number | Date, cancelToken: ReadonlyCancellationToken): Promise<boolean>;
13
+ export declare function withTimeout<T>(milliseconds: number, promiseOrProvider: ValueOrProvider<Promise<T>>, options?: {
14
+ errorMessage?: string;
15
+ }): Promise<T>;
10
16
  export declare function immediate(): Promise<void>;
11
17
  export declare function nextTick(): Promise<void>;
12
18
  export declare function animationFrame(): Promise<number>;
package/utils/timing.js CHANGED
@@ -25,12 +25,23 @@ __export(timing_exports, {
25
25
  immediate: () => immediate,
26
26
  nextTick: () => nextTick,
27
27
  timeout: () => timeout,
28
- timeoutUntil: () => timeoutUntil
28
+ timeoutUntil: () => timeoutUntil,
29
+ withTimeout: () => withTimeout
29
30
  });
30
31
  module.exports = __toCommonJS(timing_exports);
32
+ var import_timeout_error = require("../error/timeout.error.js");
31
33
  var import_rxjs = require("rxjs");
32
- async function timeout(milliseconds = 0) {
33
- return new Promise((resolve) => setTimeout(resolve, milliseconds));
34
+ var import_throw = require("./throw.js");
35
+ var import_value_or_provider = require("./value-or-provider.js");
36
+ async function timeout(milliseconds = 0, options) {
37
+ return new Promise((resolve) => {
38
+ const abortListener = () => clearTimeout(timeoutRef);
39
+ const timeoutRef = setTimeout(() => {
40
+ options?.abortSignal?.removeEventListener("abort", abortListener);
41
+ resolve();
42
+ }, milliseconds);
43
+ options?.abortSignal?.addEventListener("abort", abortListener);
44
+ });
34
45
  }
35
46
  async function timeoutUntil(timestamp) {
36
47
  const left = timestamp.valueOf() - Date.now();
@@ -47,6 +58,15 @@ async function cancelableTimeoutUntil(timestamp, cancelToken) {
47
58
  const left = timestamp.valueOf() - Date.now();
48
59
  return cancelableTimeout(left, cancelToken);
49
60
  }
61
+ async function withTimeout(milliseconds, promiseOrProvider, options) {
62
+ const abortController = new AbortController();
63
+ const promise = (0, import_value_or_provider.resolveValueOrProvider)(promiseOrProvider);
64
+ void promise.then(() => abortController.abort());
65
+ return Promise.race([
66
+ promise,
67
+ timeout(milliseconds, { abortSignal: abortController.signal }).then(() => (0, import_throw._throw)(new import_timeout_error.TimeoutError(options?.errorMessage)))
68
+ ]);
69
+ }
50
70
  async function immediate() {
51
71
  return new Promise(setImmediate);
52
72
  }
@@ -238,3 +238,9 @@ export declare function assertReadableStream<T = any>(value: any, message?: Asse
238
238
  export declare function assertNotReadableStream<T>(value: T, message?: AssertionMessage): asserts value is InferIsNotType<T, typeof isReadableStream>;
239
239
  export declare function assertReadableStreamPass<T = any>(value: any, message?: AssertionMessage): InferIsType<typeof isReadableStream>;
240
240
  export declare function assertNotReadableStreamPass<T>(value: T, message?: AssertionMessage): InferIsNotType<T, typeof isReadableStream>;
241
+ export declare function isError(value: any): value is Error;
242
+ export declare function isNotError<T>(value: T): value is InferIsNotType<T, typeof isError>;
243
+ export declare function assertError(value: any, message?: AssertionMessage): asserts value is InferIsType<typeof isError>;
244
+ export declare function assertNotError<T>(value: T, message?: AssertionMessage): asserts value is InferIsNotType<T, typeof isError>;
245
+ export declare function assertErrorPass(value: any, message?: AssertionMessage): InferIsType<typeof isError>;
246
+ export declare function assertNotErrorPass<T>(value: T, message?: AssertionMessage): InferIsNotType<T, typeof isError>;
@@ -43,6 +43,8 @@ __export(type_guards_exports, {
43
43
  assertDatePass: () => assertDatePass,
44
44
  assertDefined: () => assertDefined,
45
45
  assertDefinedPass: () => assertDefinedPass,
46
+ assertError: () => assertError,
47
+ assertErrorPass: () => assertErrorPass,
46
48
  assertFloat32Array: () => assertFloat32Array,
47
49
  assertFloat32ArrayPass: () => assertFloat32ArrayPass,
48
50
  assertFloat64Array: () => assertFloat64Array,
@@ -82,6 +84,8 @@ __export(type_guards_exports, {
82
84
  assertNotDataViewPass: () => assertNotDataViewPass,
83
85
  assertNotDate: () => assertNotDate,
84
86
  assertNotDatePass: () => assertNotDatePass,
87
+ assertNotError: () => assertNotError,
88
+ assertNotErrorPass: () => assertNotErrorPass,
85
89
  assertNotFloat32Array: () => assertNotFloat32Array,
86
90
  assertNotFloat32ArrayPass: () => assertNotFloat32ArrayPass,
87
91
  assertNotFloat64Array: () => assertNotFloat64Array,
@@ -188,6 +192,7 @@ __export(type_guards_exports, {
188
192
  isDataView: () => isDataView,
189
193
  isDate: () => isDate,
190
194
  isDefined: () => isDefined,
195
+ isError: () => isError,
191
196
  isFloat32Array: () => isFloat32Array,
192
197
  isFloat64Array: () => isFloat64Array,
193
198
  isFunction: () => isFunction,
@@ -207,6 +212,7 @@ __export(type_guards_exports, {
207
212
  isNotBoolean: () => isNotBoolean,
208
213
  isNotDataView: () => isNotDataView,
209
214
  isNotDate: () => isNotDate,
215
+ isNotError: () => isNotError,
210
216
  isNotFloat32Array: () => isNotFloat32Array,
211
217
  isNotFloat64Array: () => isNotFloat64Array,
212
218
  isNotFunction: () => isNotFunction,
@@ -1048,3 +1054,23 @@ function assertNotReadableStreamPass(value, message) {
1048
1054
  assertNotReadableStream(value, message);
1049
1055
  return value;
1050
1056
  }
1057
+ function isError(value) {
1058
+ return value instanceof Error;
1059
+ }
1060
+ function isNotError(value) {
1061
+ return !isError(value);
1062
+ }
1063
+ function assertError(value, message = "Expected value to be Error.") {
1064
+ assert(isError(value), message);
1065
+ }
1066
+ function assertNotError(value, message = "Expected value to not be Error.") {
1067
+ assert(isNotError(value), message);
1068
+ }
1069
+ function assertErrorPass(value, message) {
1070
+ assertError(value, message);
1071
+ return value;
1072
+ }
1073
+ function assertNotErrorPass(value, message) {
1074
+ assertNotError(value, message);
1075
+ return value;
1076
+ }
@@ -0,0 +1,2 @@
1
+ export type ValueOrProvider<T> = T extends () => any ? never : T | (() => T);
2
+ export declare function resolveValueOrProvider<T>(valueOrProvider: ValueOrProvider<T>): T;
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var value_or_provider_exports = {};
20
+ __export(value_or_provider_exports, {
21
+ resolveValueOrProvider: () => resolveValueOrProvider
22
+ });
23
+ module.exports = __toCommonJS(value_or_provider_exports);
24
+ var import_type_guards = require("./type-guards.js");
25
+ function resolveValueOrProvider(valueOrProvider) {
26
+ if ((0, import_type_guards.isFunction)(valueOrProvider)) {
27
+ return valueOrProvider();
28
+ }
29
+ return valueOrProvider;
30
+ }