@orpc/shared 1.7.0 → 1.7.2
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/dist/index.d.mts +5 -2
- package/dist/index.d.ts +5 -2
- package/dist/index.mjs +28 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -185,7 +185,7 @@ declare function isObject(value: unknown): value is Record<PropertyKey, unknown>
|
|
|
185
185
|
*/
|
|
186
186
|
declare function isTypescriptObject(value: unknown): value is object & Record<PropertyKey, unknown>;
|
|
187
187
|
declare function clone<T>(value: T): T;
|
|
188
|
-
declare function get(object:
|
|
188
|
+
declare function get(object: unknown, path: readonly string[]): unknown;
|
|
189
189
|
declare function isPropertyKey(value: unknown): value is PropertyKey;
|
|
190
190
|
declare const NullProtoObj: ({
|
|
191
191
|
new <T extends Record<PropertyKey, unknown>>(): T;
|
|
@@ -208,8 +208,11 @@ declare class AsyncIdQueue<T> {
|
|
|
208
208
|
assertOpen(id: string): void;
|
|
209
209
|
}
|
|
210
210
|
|
|
211
|
+
declare function streamToAsyncIteratorClass<T>(stream: ReadableStream<T>): AsyncIteratorClass<T>;
|
|
212
|
+
declare function asyncIteratorToStream<T>(iterator: AsyncIterator<T>): ReadableStream<T>;
|
|
213
|
+
|
|
211
214
|
type Value<T, TArgs extends any[] = []> = T | ((...args: TArgs) => T);
|
|
212
215
|
declare function value<T, TArgs extends any[]>(value: Value<T, TArgs>, ...args: NoInfer<TArgs>): T extends Value<infer U, any> ? U : never;
|
|
213
216
|
|
|
214
|
-
export { AsyncIdQueue, AsyncIteratorClass, EventPublisher, NullProtoObj, SequentialIdGenerator, clone, defer, findDeepMatches, get, intercept, isAsyncIteratorObject, isObject, isPropertyKey, isTypescriptObject, onError, onFinish, onStart, onSuccess, once, parseEmptyableJSON, readAsBuffer, replicateAsyncIterator, resolveMaybeOptionalOptions, sequential, splitInHalf, stringifyJSON, toArray, value };
|
|
217
|
+
export { AsyncIdQueue, AsyncIteratorClass, EventPublisher, NullProtoObj, SequentialIdGenerator, asyncIteratorToStream, clone, defer, findDeepMatches, get, intercept, isAsyncIteratorObject, isObject, isPropertyKey, isTypescriptObject, onError, onFinish, onStart, onSuccess, once, parseEmptyableJSON, readAsBuffer, replicateAsyncIterator, resolveMaybeOptionalOptions, sequential, splitInHalf, streamToAsyncIteratorClass, stringifyJSON, toArray, value };
|
|
215
218
|
export type { AnyFunction, AsyncIdQueueCloseOptions, AsyncIteratorClassCleanupFn, AsyncIteratorClassNextFn, EventPublisherOptions, EventPublisherSubscribeIteratorOptions, InterceptableOptions, Interceptor, InterceptorOptions, IntersectPick, MaybeOptionalOptions, OmitChainMethodDeep, OnFinishState, PromiseWithError, Registry, Segment, SetOptional, ThrowableError, Value };
|
package/dist/index.d.ts
CHANGED
|
@@ -185,7 +185,7 @@ declare function isObject(value: unknown): value is Record<PropertyKey, unknown>
|
|
|
185
185
|
*/
|
|
186
186
|
declare function isTypescriptObject(value: unknown): value is object & Record<PropertyKey, unknown>;
|
|
187
187
|
declare function clone<T>(value: T): T;
|
|
188
|
-
declare function get(object:
|
|
188
|
+
declare function get(object: unknown, path: readonly string[]): unknown;
|
|
189
189
|
declare function isPropertyKey(value: unknown): value is PropertyKey;
|
|
190
190
|
declare const NullProtoObj: ({
|
|
191
191
|
new <T extends Record<PropertyKey, unknown>>(): T;
|
|
@@ -208,8 +208,11 @@ declare class AsyncIdQueue<T> {
|
|
|
208
208
|
assertOpen(id: string): void;
|
|
209
209
|
}
|
|
210
210
|
|
|
211
|
+
declare function streamToAsyncIteratorClass<T>(stream: ReadableStream<T>): AsyncIteratorClass<T>;
|
|
212
|
+
declare function asyncIteratorToStream<T>(iterator: AsyncIterator<T>): ReadableStream<T>;
|
|
213
|
+
|
|
211
214
|
type Value<T, TArgs extends any[] = []> = T | ((...args: TArgs) => T);
|
|
212
215
|
declare function value<T, TArgs extends any[]>(value: Value<T, TArgs>, ...args: NoInfer<TArgs>): T extends Value<infer U, any> ? U : never;
|
|
213
216
|
|
|
214
|
-
export { AsyncIdQueue, AsyncIteratorClass, EventPublisher, NullProtoObj, SequentialIdGenerator, clone, defer, findDeepMatches, get, intercept, isAsyncIteratorObject, isObject, isPropertyKey, isTypescriptObject, onError, onFinish, onStart, onSuccess, once, parseEmptyableJSON, readAsBuffer, replicateAsyncIterator, resolveMaybeOptionalOptions, sequential, splitInHalf, stringifyJSON, toArray, value };
|
|
217
|
+
export { AsyncIdQueue, AsyncIteratorClass, EventPublisher, NullProtoObj, SequentialIdGenerator, asyncIteratorToStream, clone, defer, findDeepMatches, get, intercept, isAsyncIteratorObject, isObject, isPropertyKey, isTypescriptObject, onError, onFinish, onStart, onSuccess, once, parseEmptyableJSON, readAsBuffer, replicateAsyncIterator, resolveMaybeOptionalOptions, sequential, splitInHalf, streamToAsyncIteratorClass, stringifyJSON, toArray, value };
|
|
215
218
|
export type { AnyFunction, AsyncIdQueueCloseOptions, AsyncIteratorClassCleanupFn, AsyncIteratorClassNextFn, EventPublisherOptions, EventPublisherSubscribeIteratorOptions, InterceptableOptions, Interceptor, InterceptorOptions, IntersectPick, MaybeOptionalOptions, OmitChainMethodDeep, OnFinishState, PromiseWithError, Registry, Segment, SetOptional, ThrowableError, Value };
|
package/dist/index.mjs
CHANGED
|
@@ -449,6 +449,33 @@ const NullProtoObj = /* @__PURE__ */ (() => {
|
|
|
449
449
|
return e;
|
|
450
450
|
})();
|
|
451
451
|
|
|
452
|
+
function streamToAsyncIteratorClass(stream) {
|
|
453
|
+
const reader = stream.getReader();
|
|
454
|
+
return new AsyncIteratorClass(
|
|
455
|
+
async () => {
|
|
456
|
+
return reader.read();
|
|
457
|
+
},
|
|
458
|
+
async () => {
|
|
459
|
+
await reader.cancel();
|
|
460
|
+
}
|
|
461
|
+
);
|
|
462
|
+
}
|
|
463
|
+
function asyncIteratorToStream(iterator) {
|
|
464
|
+
return new ReadableStream({
|
|
465
|
+
async pull(controller) {
|
|
466
|
+
const { done, value } = await iterator.next();
|
|
467
|
+
if (done) {
|
|
468
|
+
controller.close();
|
|
469
|
+
} else {
|
|
470
|
+
controller.enqueue(value);
|
|
471
|
+
}
|
|
472
|
+
},
|
|
473
|
+
async cancel() {
|
|
474
|
+
await iterator.return?.();
|
|
475
|
+
}
|
|
476
|
+
});
|
|
477
|
+
}
|
|
478
|
+
|
|
452
479
|
function value(value2, ...args) {
|
|
453
480
|
if (typeof value2 === "function") {
|
|
454
481
|
return value2(...args);
|
|
@@ -456,4 +483,4 @@ function value(value2, ...args) {
|
|
|
456
483
|
return value2;
|
|
457
484
|
}
|
|
458
485
|
|
|
459
|
-
export { AsyncIdQueue, AsyncIteratorClass, EventPublisher, NullProtoObj, SequentialIdGenerator, clone, defer, findDeepMatches, get, intercept, isAsyncIteratorObject, isObject, isPropertyKey, isTypescriptObject, onError, onFinish, onStart, onSuccess, once, parseEmptyableJSON, readAsBuffer, replicateAsyncIterator, resolveMaybeOptionalOptions, sequential, splitInHalf, stringifyJSON, toArray, value };
|
|
486
|
+
export { AsyncIdQueue, AsyncIteratorClass, EventPublisher, NullProtoObj, SequentialIdGenerator, asyncIteratorToStream, clone, defer, findDeepMatches, get, intercept, isAsyncIteratorObject, isObject, isPropertyKey, isTypescriptObject, onError, onFinish, onStart, onSuccess, once, parseEmptyableJSON, readAsBuffer, replicateAsyncIterator, resolveMaybeOptionalOptions, sequential, splitInHalf, streamToAsyncIteratorClass, stringifyJSON, toArray, value };
|