@orpc/shared 1.4.1 → 1.4.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.
- package/README.md +4 -6
- package/dist/index.d.mts +61 -2
- package/dist/index.d.ts +61 -2
- package/dist/index.mjs +143 -66
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -54,14 +54,12 @@ You can find the full documentation [here](https://orpc.unnoq.com).
|
|
|
54
54
|
- [@orpc/contract](https://www.npmjs.com/package/@orpc/contract): Build your API contract.
|
|
55
55
|
- [@orpc/server](https://www.npmjs.com/package/@orpc/server): Build your API or implement API contract.
|
|
56
56
|
- [@orpc/client](https://www.npmjs.com/package/@orpc/client): Consume your API on the client with type-safety.
|
|
57
|
-
- [@orpc/
|
|
57
|
+
- [@orpc/openapi](https://www.npmjs.com/package/@orpc/openapi): Generate OpenAPI specs and handle OpenAPI requests.
|
|
58
|
+
- [@orpc/nest](https://www.npmjs.com/package/@orpc/nest): Deeply integrate oRPC with [NestJS](https://nestjs.com/).
|
|
58
59
|
- [@orpc/react](https://www.npmjs.com/package/@orpc/react): Utilities for integrating oRPC with React and React Server Actions.
|
|
59
|
-
- [@orpc/
|
|
60
|
-
- [@orpc/vue-query](https://www.npmjs.com/package/@orpc/vue-query): Integration with [Vue Query](https://tanstack.com/query/latest/docs/framework/vue/overview).
|
|
61
|
-
- [@orpc/solid-query](https://www.npmjs.com/package/@orpc/solid-query): Integration with [Solid Query](https://tanstack.com/query/latest/docs/framework/solid/overview).
|
|
62
|
-
- [@orpc/svelte-query](https://www.npmjs.com/package/@orpc/svelte-query): Integration with [Svelte Query](https://tanstack.com/query/latest/docs/framework/svelte/overview).
|
|
60
|
+
- [@orpc/tanstack-query](https://www.npmjs.com/package/@orpc/tanstack-query): [TanStack Query](https://tanstack.com/query/latest) integration.
|
|
63
61
|
- [@orpc/vue-colada](https://www.npmjs.com/package/@orpc/vue-colada): Integration with [Pinia Colada](https://pinia-colada.esm.dev/).
|
|
64
|
-
- [@orpc/
|
|
62
|
+
- [@orpc/hey-api](https://www.npmjs.com/package/@orpc/hey-api): [Hey API](https://heyapi.dev/) integration.
|
|
65
63
|
- [@orpc/zod](https://www.npmjs.com/package/@orpc/zod): More schemas that [Zod](https://zod.dev/) doesn't support yet.
|
|
66
64
|
- [@orpc/valibot](https://www.npmjs.com/package/@orpc/valibot): OpenAPI spec generation from [Valibot](https://valibot.dev/).
|
|
67
65
|
- [@orpc/arktype](https://www.npmjs.com/package/@orpc/arktype): OpenAPI spec generation from [ArkType](https://arktype.io/).
|
package/dist/index.d.mts
CHANGED
|
@@ -20,6 +20,65 @@ type OmitChainMethodDeep<T extends object, K extends keyof any> = {
|
|
|
20
20
|
[P in keyof Omit<T, K>]: T[P] extends AnyFunction ? ((...args: Parameters<T[P]>) => OmitChainMethodDeep<ReturnType<T[P]>, K>) : T[P];
|
|
21
21
|
};
|
|
22
22
|
|
|
23
|
+
interface EventPublisherOptions {
|
|
24
|
+
/**
|
|
25
|
+
* Maximum number of events to buffer for async iterator subscribers.
|
|
26
|
+
*
|
|
27
|
+
* If the buffer exceeds this limit, the oldest event is dropped.
|
|
28
|
+
* This prevents unbounded memory growth if consumers process events slowly.
|
|
29
|
+
*
|
|
30
|
+
* Set to:
|
|
31
|
+
* - `0`: Disable buffering. Events must be consumed before the next one arrives.
|
|
32
|
+
* - `1`: Only keep the latest event. Useful for real-time updates where only the most recent value matters.
|
|
33
|
+
* - `Infinity`: Keep all events. Ensures no data loss, but may lead to high memory usage.
|
|
34
|
+
*
|
|
35
|
+
* @default 100
|
|
36
|
+
*/
|
|
37
|
+
maxBufferedEvents?: number;
|
|
38
|
+
}
|
|
39
|
+
interface EventPublisherSubscribeIteratorOptions extends EventPublisherOptions {
|
|
40
|
+
/**
|
|
41
|
+
* Aborts the async iterator. Throws if aborted before or during pulling.
|
|
42
|
+
*/
|
|
43
|
+
signal?: AbortSignal;
|
|
44
|
+
}
|
|
45
|
+
declare class EventPublisher<T extends Record<PropertyKey, any>> {
|
|
46
|
+
#private;
|
|
47
|
+
constructor(options?: EventPublisherOptions);
|
|
48
|
+
get size(): number;
|
|
49
|
+
/**
|
|
50
|
+
* Emits an event and delivers the payload to all subscribed listeners.
|
|
51
|
+
*/
|
|
52
|
+
publish<K extends keyof T>(event: K, payload: T[K]): void;
|
|
53
|
+
/**
|
|
54
|
+
* Subscribes to a specific event using a callback function.
|
|
55
|
+
* Returns an unsubscribe function to remove the listener.
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* ```ts
|
|
59
|
+
* const unsubscribe = publisher.subscribe('event', (payload) => {
|
|
60
|
+
* console.log(payload)
|
|
61
|
+
* })
|
|
62
|
+
*
|
|
63
|
+
* // Later
|
|
64
|
+
* unsubscribe()
|
|
65
|
+
* ```
|
|
66
|
+
*/
|
|
67
|
+
subscribe<K extends keyof T>(event: K, listener: (payload: T[K]) => void): () => void;
|
|
68
|
+
/**
|
|
69
|
+
* Subscribes to a specific event using an async iterator.
|
|
70
|
+
* Useful for `for await...of` loops with optional buffering and abort support.
|
|
71
|
+
*
|
|
72
|
+
* @example
|
|
73
|
+
* ```ts
|
|
74
|
+
* for await (const payload of publisher.subscribe('event', { signal })) {
|
|
75
|
+
* console.log(payload)
|
|
76
|
+
* }
|
|
77
|
+
* ```
|
|
78
|
+
*/
|
|
79
|
+
subscribe<K extends keyof T>(event: K, options?: EventPublisherSubscribeIteratorOptions): AsyncGenerator<T[K]> & AsyncIteratorObject<T[K]>;
|
|
80
|
+
}
|
|
81
|
+
|
|
23
82
|
declare class SequentialIdGenerator {
|
|
24
83
|
private nextId;
|
|
25
84
|
generate(): number;
|
|
@@ -125,5 +184,5 @@ declare class AsyncIdQueue<T> {
|
|
|
125
184
|
type Value<T, TArgs extends any[] = []> = T | ((...args: TArgs) => T);
|
|
126
185
|
declare function value<T, TArgs extends any[]>(value: Value<T, TArgs>, ...args: NoInfer<TArgs>): T extends Value<infer U, any> ? U : never;
|
|
127
186
|
|
|
128
|
-
export { AsyncIdQueue, NullProtoObj, SequentialIdGenerator, clone, createAsyncIteratorObject, defer, findDeepMatches, get, intercept, isAsyncIteratorObject, isObject, isPropertyKey, isTypescriptObject, onError, onFinish, onStart, onSuccess, once, parseEmptyableJSON, replicateAsyncIterator, resolveMaybeOptionalOptions, sequential, splitInHalf, stringifyJSON, toArray, value };
|
|
129
|
-
export type { AnyFunction, AsyncIdQueueCloseOptions, CreateAsyncIteratorObjectCleanupFn, InterceptableOptions, Interceptor, InterceptorOptions, IntersectPick, MaybeOptionalOptions, OmitChainMethodDeep, OnFinishState, PromiseWithError, Registry, Segment, SetOptional, ThrowableError, Value };
|
|
187
|
+
export { AsyncIdQueue, EventPublisher, NullProtoObj, SequentialIdGenerator, clone, createAsyncIteratorObject, defer, findDeepMatches, get, intercept, isAsyncIteratorObject, isObject, isPropertyKey, isTypescriptObject, onError, onFinish, onStart, onSuccess, once, parseEmptyableJSON, replicateAsyncIterator, resolveMaybeOptionalOptions, sequential, splitInHalf, stringifyJSON, toArray, value };
|
|
188
|
+
export type { AnyFunction, AsyncIdQueueCloseOptions, CreateAsyncIteratorObjectCleanupFn, EventPublisherOptions, EventPublisherSubscribeIteratorOptions, InterceptableOptions, Interceptor, InterceptorOptions, IntersectPick, MaybeOptionalOptions, OmitChainMethodDeep, OnFinishState, PromiseWithError, Registry, Segment, SetOptional, ThrowableError, Value };
|
package/dist/index.d.ts
CHANGED
|
@@ -20,6 +20,65 @@ type OmitChainMethodDeep<T extends object, K extends keyof any> = {
|
|
|
20
20
|
[P in keyof Omit<T, K>]: T[P] extends AnyFunction ? ((...args: Parameters<T[P]>) => OmitChainMethodDeep<ReturnType<T[P]>, K>) : T[P];
|
|
21
21
|
};
|
|
22
22
|
|
|
23
|
+
interface EventPublisherOptions {
|
|
24
|
+
/**
|
|
25
|
+
* Maximum number of events to buffer for async iterator subscribers.
|
|
26
|
+
*
|
|
27
|
+
* If the buffer exceeds this limit, the oldest event is dropped.
|
|
28
|
+
* This prevents unbounded memory growth if consumers process events slowly.
|
|
29
|
+
*
|
|
30
|
+
* Set to:
|
|
31
|
+
* - `0`: Disable buffering. Events must be consumed before the next one arrives.
|
|
32
|
+
* - `1`: Only keep the latest event. Useful for real-time updates where only the most recent value matters.
|
|
33
|
+
* - `Infinity`: Keep all events. Ensures no data loss, but may lead to high memory usage.
|
|
34
|
+
*
|
|
35
|
+
* @default 100
|
|
36
|
+
*/
|
|
37
|
+
maxBufferedEvents?: number;
|
|
38
|
+
}
|
|
39
|
+
interface EventPublisherSubscribeIteratorOptions extends EventPublisherOptions {
|
|
40
|
+
/**
|
|
41
|
+
* Aborts the async iterator. Throws if aborted before or during pulling.
|
|
42
|
+
*/
|
|
43
|
+
signal?: AbortSignal;
|
|
44
|
+
}
|
|
45
|
+
declare class EventPublisher<T extends Record<PropertyKey, any>> {
|
|
46
|
+
#private;
|
|
47
|
+
constructor(options?: EventPublisherOptions);
|
|
48
|
+
get size(): number;
|
|
49
|
+
/**
|
|
50
|
+
* Emits an event and delivers the payload to all subscribed listeners.
|
|
51
|
+
*/
|
|
52
|
+
publish<K extends keyof T>(event: K, payload: T[K]): void;
|
|
53
|
+
/**
|
|
54
|
+
* Subscribes to a specific event using a callback function.
|
|
55
|
+
* Returns an unsubscribe function to remove the listener.
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* ```ts
|
|
59
|
+
* const unsubscribe = publisher.subscribe('event', (payload) => {
|
|
60
|
+
* console.log(payload)
|
|
61
|
+
* })
|
|
62
|
+
*
|
|
63
|
+
* // Later
|
|
64
|
+
* unsubscribe()
|
|
65
|
+
* ```
|
|
66
|
+
*/
|
|
67
|
+
subscribe<K extends keyof T>(event: K, listener: (payload: T[K]) => void): () => void;
|
|
68
|
+
/**
|
|
69
|
+
* Subscribes to a specific event using an async iterator.
|
|
70
|
+
* Useful for `for await...of` loops with optional buffering and abort support.
|
|
71
|
+
*
|
|
72
|
+
* @example
|
|
73
|
+
* ```ts
|
|
74
|
+
* for await (const payload of publisher.subscribe('event', { signal })) {
|
|
75
|
+
* console.log(payload)
|
|
76
|
+
* }
|
|
77
|
+
* ```
|
|
78
|
+
*/
|
|
79
|
+
subscribe<K extends keyof T>(event: K, options?: EventPublisherSubscribeIteratorOptions): AsyncGenerator<T[K]> & AsyncIteratorObject<T[K]>;
|
|
80
|
+
}
|
|
81
|
+
|
|
23
82
|
declare class SequentialIdGenerator {
|
|
24
83
|
private nextId;
|
|
25
84
|
generate(): number;
|
|
@@ -125,5 +184,5 @@ declare class AsyncIdQueue<T> {
|
|
|
125
184
|
type Value<T, TArgs extends any[] = []> = T | ((...args: TArgs) => T);
|
|
126
185
|
declare function value<T, TArgs extends any[]>(value: Value<T, TArgs>, ...args: NoInfer<TArgs>): T extends Value<infer U, any> ? U : never;
|
|
127
186
|
|
|
128
|
-
export { AsyncIdQueue, NullProtoObj, SequentialIdGenerator, clone, createAsyncIteratorObject, defer, findDeepMatches, get, intercept, isAsyncIteratorObject, isObject, isPropertyKey, isTypescriptObject, onError, onFinish, onStart, onSuccess, once, parseEmptyableJSON, replicateAsyncIterator, resolveMaybeOptionalOptions, sequential, splitInHalf, stringifyJSON, toArray, value };
|
|
129
|
-
export type { AnyFunction, AsyncIdQueueCloseOptions, CreateAsyncIteratorObjectCleanupFn, InterceptableOptions, Interceptor, InterceptorOptions, IntersectPick, MaybeOptionalOptions, OmitChainMethodDeep, OnFinishState, PromiseWithError, Registry, Segment, SetOptional, ThrowableError, Value };
|
|
187
|
+
export { AsyncIdQueue, EventPublisher, NullProtoObj, SequentialIdGenerator, clone, createAsyncIteratorObject, defer, findDeepMatches, get, intercept, isAsyncIteratorObject, isObject, isPropertyKey, isTypescriptObject, onError, onFinish, onStart, onSuccess, once, parseEmptyableJSON, replicateAsyncIterator, resolveMaybeOptionalOptions, sequential, splitInHalf, stringifyJSON, toArray, value };
|
|
188
|
+
export type { AnyFunction, AsyncIdQueueCloseOptions, CreateAsyncIteratorObjectCleanupFn, EventPublisherOptions, EventPublisherSubscribeIteratorOptions, InterceptableOptions, Interceptor, InterceptorOptions, IntersectPick, MaybeOptionalOptions, OmitChainMethodDeep, OnFinishState, PromiseWithError, Registry, Segment, SetOptional, ThrowableError, Value };
|
package/dist/index.mjs
CHANGED
|
@@ -33,76 +33,13 @@ function sequential(fn) {
|
|
|
33
33
|
};
|
|
34
34
|
}
|
|
35
35
|
function defer(callback) {
|
|
36
|
-
if (
|
|
37
|
-
|
|
36
|
+
if (typeof setTimeout === "function") {
|
|
37
|
+
setTimeout(callback, 0);
|
|
38
38
|
} else {
|
|
39
39
|
Promise.resolve().then(() => Promise.resolve().then(() => Promise.resolve().then(callback)));
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
class SequentialIdGenerator {
|
|
44
|
-
nextId = 0;
|
|
45
|
-
generate() {
|
|
46
|
-
if (this.nextId === Number.MAX_SAFE_INTEGER) {
|
|
47
|
-
this.nextId = 0;
|
|
48
|
-
return Number.MAX_SAFE_INTEGER;
|
|
49
|
-
}
|
|
50
|
-
return this.nextId++;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
function onStart(callback) {
|
|
55
|
-
return async (options, ...rest) => {
|
|
56
|
-
await callback(options, ...rest);
|
|
57
|
-
return await options.next();
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
function onSuccess(callback) {
|
|
61
|
-
return async (options, ...rest) => {
|
|
62
|
-
const result = await options.next();
|
|
63
|
-
await callback(result, options, ...rest);
|
|
64
|
-
return result;
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
function onError(callback) {
|
|
68
|
-
return async (options, ...rest) => {
|
|
69
|
-
try {
|
|
70
|
-
return await options.next();
|
|
71
|
-
} catch (error) {
|
|
72
|
-
await callback(error, options, ...rest);
|
|
73
|
-
throw error;
|
|
74
|
-
}
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
function onFinish(callback) {
|
|
78
|
-
let state;
|
|
79
|
-
return async (options, ...rest) => {
|
|
80
|
-
try {
|
|
81
|
-
const result = await options.next();
|
|
82
|
-
state = [null, result, true];
|
|
83
|
-
return result;
|
|
84
|
-
} catch (error) {
|
|
85
|
-
state = [error, void 0, false];
|
|
86
|
-
throw error;
|
|
87
|
-
} finally {
|
|
88
|
-
await callback(state, options, ...rest);
|
|
89
|
-
}
|
|
90
|
-
};
|
|
91
|
-
}
|
|
92
|
-
function intercept(interceptors, options, main) {
|
|
93
|
-
const next = (options2, index) => {
|
|
94
|
-
const interceptor = interceptors[index];
|
|
95
|
-
if (!interceptor) {
|
|
96
|
-
return main(options2);
|
|
97
|
-
}
|
|
98
|
-
return interceptor({
|
|
99
|
-
...options2,
|
|
100
|
-
next: (newOptions = options2) => next(newOptions, index + 1)
|
|
101
|
-
});
|
|
102
|
-
};
|
|
103
|
-
return next(options, 0);
|
|
104
|
-
}
|
|
105
|
-
|
|
106
43
|
class AsyncIdQueue {
|
|
107
44
|
openIds = /* @__PURE__ */ new Set();
|
|
108
45
|
items = /* @__PURE__ */ new Map();
|
|
@@ -289,6 +226,146 @@ function replicateAsyncIterator(source, count) {
|
|
|
289
226
|
return replicated;
|
|
290
227
|
}
|
|
291
228
|
|
|
229
|
+
class EventPublisher {
|
|
230
|
+
#listenersMap = /* @__PURE__ */ new Map();
|
|
231
|
+
#maxBufferedEvents;
|
|
232
|
+
constructor(options = {}) {
|
|
233
|
+
this.#maxBufferedEvents = options.maxBufferedEvents ?? 100;
|
|
234
|
+
}
|
|
235
|
+
get size() {
|
|
236
|
+
return this.#listenersMap.size;
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* Emits an event and delivers the payload to all subscribed listeners.
|
|
240
|
+
*/
|
|
241
|
+
publish(event, payload) {
|
|
242
|
+
const listeners = this.#listenersMap.get(event);
|
|
243
|
+
if (!listeners) {
|
|
244
|
+
return;
|
|
245
|
+
}
|
|
246
|
+
for (const listener of listeners) {
|
|
247
|
+
listener(payload);
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
subscribe(event, listenerOrOptions) {
|
|
251
|
+
if (typeof listenerOrOptions === "function") {
|
|
252
|
+
let listeners = this.#listenersMap.get(event);
|
|
253
|
+
if (!listeners) {
|
|
254
|
+
this.#listenersMap.set(event, listeners = /* @__PURE__ */ new Set());
|
|
255
|
+
}
|
|
256
|
+
listeners.add(listenerOrOptions);
|
|
257
|
+
return () => {
|
|
258
|
+
listeners.delete(listenerOrOptions);
|
|
259
|
+
if (listeners.size === 0) {
|
|
260
|
+
this.#listenersMap.delete(event);
|
|
261
|
+
}
|
|
262
|
+
};
|
|
263
|
+
}
|
|
264
|
+
const signal = listenerOrOptions?.signal;
|
|
265
|
+
const maxBufferedEvents = listenerOrOptions?.maxBufferedEvents ?? this.#maxBufferedEvents;
|
|
266
|
+
const bufferedEvents = [];
|
|
267
|
+
const pullResolvers = [];
|
|
268
|
+
const unsubscribe = this.subscribe(event, (payload) => {
|
|
269
|
+
const resolver = pullResolvers.shift();
|
|
270
|
+
if (resolver) {
|
|
271
|
+
resolver[0]({ done: false, value: payload });
|
|
272
|
+
} else {
|
|
273
|
+
bufferedEvents.push(payload);
|
|
274
|
+
if (bufferedEvents.length > maxBufferedEvents) {
|
|
275
|
+
bufferedEvents.shift();
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
});
|
|
279
|
+
const abortListener = (event2) => {
|
|
280
|
+
unsubscribe();
|
|
281
|
+
pullResolvers.forEach((resolver) => resolver[1](event2.target.reason));
|
|
282
|
+
pullResolvers.length = 0;
|
|
283
|
+
bufferedEvents.length = 0;
|
|
284
|
+
};
|
|
285
|
+
signal?.addEventListener("abort", abortListener, { once: true });
|
|
286
|
+
return createAsyncIteratorObject(async () => {
|
|
287
|
+
if (signal?.aborted) {
|
|
288
|
+
throw signal.reason;
|
|
289
|
+
}
|
|
290
|
+
if (bufferedEvents.length > 0) {
|
|
291
|
+
return { done: false, value: bufferedEvents.shift() };
|
|
292
|
+
}
|
|
293
|
+
return new Promise((resolve, reject) => {
|
|
294
|
+
pullResolvers.push([resolve, reject]);
|
|
295
|
+
});
|
|
296
|
+
}, async () => {
|
|
297
|
+
unsubscribe();
|
|
298
|
+
signal?.removeEventListener("abort", abortListener);
|
|
299
|
+
pullResolvers.forEach((resolver) => resolver[0]({ done: true, value: void 0 }));
|
|
300
|
+
pullResolvers.length = 0;
|
|
301
|
+
bufferedEvents.length = 0;
|
|
302
|
+
});
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
class SequentialIdGenerator {
|
|
307
|
+
nextId = 0;
|
|
308
|
+
generate() {
|
|
309
|
+
if (this.nextId === Number.MAX_SAFE_INTEGER) {
|
|
310
|
+
this.nextId = 0;
|
|
311
|
+
return Number.MAX_SAFE_INTEGER;
|
|
312
|
+
}
|
|
313
|
+
return this.nextId++;
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
function onStart(callback) {
|
|
318
|
+
return async (options, ...rest) => {
|
|
319
|
+
await callback(options, ...rest);
|
|
320
|
+
return await options.next();
|
|
321
|
+
};
|
|
322
|
+
}
|
|
323
|
+
function onSuccess(callback) {
|
|
324
|
+
return async (options, ...rest) => {
|
|
325
|
+
const result = await options.next();
|
|
326
|
+
await callback(result, options, ...rest);
|
|
327
|
+
return result;
|
|
328
|
+
};
|
|
329
|
+
}
|
|
330
|
+
function onError(callback) {
|
|
331
|
+
return async (options, ...rest) => {
|
|
332
|
+
try {
|
|
333
|
+
return await options.next();
|
|
334
|
+
} catch (error) {
|
|
335
|
+
await callback(error, options, ...rest);
|
|
336
|
+
throw error;
|
|
337
|
+
}
|
|
338
|
+
};
|
|
339
|
+
}
|
|
340
|
+
function onFinish(callback) {
|
|
341
|
+
let state;
|
|
342
|
+
return async (options, ...rest) => {
|
|
343
|
+
try {
|
|
344
|
+
const result = await options.next();
|
|
345
|
+
state = [null, result, true];
|
|
346
|
+
return result;
|
|
347
|
+
} catch (error) {
|
|
348
|
+
state = [error, void 0, false];
|
|
349
|
+
throw error;
|
|
350
|
+
} finally {
|
|
351
|
+
await callback(state, options, ...rest);
|
|
352
|
+
}
|
|
353
|
+
};
|
|
354
|
+
}
|
|
355
|
+
function intercept(interceptors, options, main) {
|
|
356
|
+
const next = (options2, index) => {
|
|
357
|
+
const interceptor = interceptors[index];
|
|
358
|
+
if (!interceptor) {
|
|
359
|
+
return main(options2);
|
|
360
|
+
}
|
|
361
|
+
return interceptor({
|
|
362
|
+
...options2,
|
|
363
|
+
next: (newOptions = options2) => next(newOptions, index + 1)
|
|
364
|
+
});
|
|
365
|
+
};
|
|
366
|
+
return next(options, 0);
|
|
367
|
+
}
|
|
368
|
+
|
|
292
369
|
function parseEmptyableJSON(text) {
|
|
293
370
|
if (!text) {
|
|
294
371
|
return void 0;
|
|
@@ -366,4 +443,4 @@ function value(value2, ...args) {
|
|
|
366
443
|
return value2;
|
|
367
444
|
}
|
|
368
445
|
|
|
369
|
-
export { AsyncIdQueue, NullProtoObj, SequentialIdGenerator, clone, createAsyncIteratorObject, defer, findDeepMatches, get, intercept, isAsyncIteratorObject, isObject, isPropertyKey, isTypescriptObject, onError, onFinish, onStart, onSuccess, once, parseEmptyableJSON, replicateAsyncIterator, resolveMaybeOptionalOptions, sequential, splitInHalf, stringifyJSON, toArray, value };
|
|
446
|
+
export { AsyncIdQueue, EventPublisher, NullProtoObj, SequentialIdGenerator, clone, createAsyncIteratorObject, defer, findDeepMatches, get, intercept, isAsyncIteratorObject, isObject, isPropertyKey, isTypescriptObject, onError, onFinish, onStart, onSuccess, once, parseEmptyableJSON, replicateAsyncIterator, resolveMaybeOptionalOptions, sequential, splitInHalf, stringifyJSON, toArray, value };
|