@orpc/shared 0.0.0-next.e82d760 → 0.0.0-next.e8524dc
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 +9 -9
- package/dist/index.d.ts +9 -9
- package/dist/index.mjs +12 -10
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Promisable } from 'type-fest';
|
|
2
|
-
export { IsEqual, IsNever,
|
|
2
|
+
export { IsEqual, IsNever, PartialDeep, Promisable } from 'type-fest';
|
|
3
3
|
export { group, guard, mapEntries, mapValues, omit } from 'radash';
|
|
4
4
|
|
|
5
5
|
type MaybeOptionalOptions<TOptions> = Record<never, never> extends TOptions ? [options?: TOptions] : [options: TOptions];
|
|
@@ -80,8 +80,8 @@ declare class EventPublisher<T extends Record<PropertyKey, any>> {
|
|
|
80
80
|
}
|
|
81
81
|
|
|
82
82
|
declare class SequentialIdGenerator {
|
|
83
|
-
private
|
|
84
|
-
generate():
|
|
83
|
+
private nextId;
|
|
84
|
+
generate(): number;
|
|
85
85
|
}
|
|
86
86
|
|
|
87
87
|
type SetOptional<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
|
|
@@ -185,7 +185,7 @@ declare const NullProtoObj: ({
|
|
|
185
185
|
});
|
|
186
186
|
|
|
187
187
|
interface AsyncIdQueueCloseOptions {
|
|
188
|
-
id?:
|
|
188
|
+
id?: number;
|
|
189
189
|
reason?: unknown;
|
|
190
190
|
}
|
|
191
191
|
declare class AsyncIdQueue<T> {
|
|
@@ -193,12 +193,12 @@ declare class AsyncIdQueue<T> {
|
|
|
193
193
|
private readonly items;
|
|
194
194
|
private readonly pendingPulls;
|
|
195
195
|
get length(): number;
|
|
196
|
-
open(id:
|
|
197
|
-
isOpen(id:
|
|
198
|
-
push(id:
|
|
199
|
-
pull(id:
|
|
196
|
+
open(id: number): void;
|
|
197
|
+
isOpen(id: number): boolean;
|
|
198
|
+
push(id: number, item: T): void;
|
|
199
|
+
pull(id: number): Promise<T>;
|
|
200
200
|
close({ id, reason }?: AsyncIdQueueCloseOptions): void;
|
|
201
|
-
assertOpen(id:
|
|
201
|
+
assertOpen(id: number): void;
|
|
202
202
|
}
|
|
203
203
|
|
|
204
204
|
type Value<T, TArgs extends any[] = []> = T | ((...args: TArgs) => T);
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Promisable } from 'type-fest';
|
|
2
|
-
export { IsEqual, IsNever,
|
|
2
|
+
export { IsEqual, IsNever, PartialDeep, Promisable } from 'type-fest';
|
|
3
3
|
export { group, guard, mapEntries, mapValues, omit } from 'radash';
|
|
4
4
|
|
|
5
5
|
type MaybeOptionalOptions<TOptions> = Record<never, never> extends TOptions ? [options?: TOptions] : [options: TOptions];
|
|
@@ -80,8 +80,8 @@ declare class EventPublisher<T extends Record<PropertyKey, any>> {
|
|
|
80
80
|
}
|
|
81
81
|
|
|
82
82
|
declare class SequentialIdGenerator {
|
|
83
|
-
private
|
|
84
|
-
generate():
|
|
83
|
+
private nextId;
|
|
84
|
+
generate(): number;
|
|
85
85
|
}
|
|
86
86
|
|
|
87
87
|
type SetOptional<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
|
|
@@ -185,7 +185,7 @@ declare const NullProtoObj: ({
|
|
|
185
185
|
});
|
|
186
186
|
|
|
187
187
|
interface AsyncIdQueueCloseOptions {
|
|
188
|
-
id?:
|
|
188
|
+
id?: number;
|
|
189
189
|
reason?: unknown;
|
|
190
190
|
}
|
|
191
191
|
declare class AsyncIdQueue<T> {
|
|
@@ -193,12 +193,12 @@ declare class AsyncIdQueue<T> {
|
|
|
193
193
|
private readonly items;
|
|
194
194
|
private readonly pendingPulls;
|
|
195
195
|
get length(): number;
|
|
196
|
-
open(id:
|
|
197
|
-
isOpen(id:
|
|
198
|
-
push(id:
|
|
199
|
-
pull(id:
|
|
196
|
+
open(id: number): void;
|
|
197
|
+
isOpen(id: number): boolean;
|
|
198
|
+
push(id: number, item: T): void;
|
|
199
|
+
pull(id: number): Promise<T>;
|
|
200
200
|
close({ id, reason }?: AsyncIdQueueCloseOptions): void;
|
|
201
|
-
assertOpen(id:
|
|
201
|
+
assertOpen(id: number): void;
|
|
202
202
|
}
|
|
203
203
|
|
|
204
204
|
type Value<T, TArgs extends any[] = []> = T | ((...args: TArgs) => T);
|
package/dist/index.mjs
CHANGED
|
@@ -194,8 +194,8 @@ function replicateAsyncIterator(source, count) {
|
|
|
194
194
|
while (true) {
|
|
195
195
|
const item = await source.next();
|
|
196
196
|
for (let id = 0; id < count; id++) {
|
|
197
|
-
if (queue.isOpen(id
|
|
198
|
-
queue.push(id
|
|
197
|
+
if (queue.isOpen(id)) {
|
|
198
|
+
queue.push(id, item);
|
|
199
199
|
}
|
|
200
200
|
}
|
|
201
201
|
if (item.done) {
|
|
@@ -207,12 +207,12 @@ function replicateAsyncIterator(source, count) {
|
|
|
207
207
|
}
|
|
208
208
|
});
|
|
209
209
|
for (let id = 0; id < count; id++) {
|
|
210
|
-
queue.open(id
|
|
210
|
+
queue.open(id);
|
|
211
211
|
replicated.push(new AsyncIteratorClass(
|
|
212
212
|
() => {
|
|
213
213
|
start();
|
|
214
214
|
return new Promise((resolve, reject) => {
|
|
215
|
-
queue.pull(id
|
|
215
|
+
queue.pull(id).then(resolve).catch(reject);
|
|
216
216
|
defer(() => {
|
|
217
217
|
if (error) {
|
|
218
218
|
reject(error.value);
|
|
@@ -221,9 +221,9 @@ function replicateAsyncIterator(source, count) {
|
|
|
221
221
|
});
|
|
222
222
|
},
|
|
223
223
|
async (reason) => {
|
|
224
|
-
queue.close({ id
|
|
224
|
+
queue.close({ id });
|
|
225
225
|
if (reason !== "next") {
|
|
226
|
-
if (replicated.every((_, id2) => !queue.isOpen(id2
|
|
226
|
+
if (replicated.every((_, id2) => !queue.isOpen(id2))) {
|
|
227
227
|
await source?.return?.();
|
|
228
228
|
}
|
|
229
229
|
}
|
|
@@ -312,11 +312,13 @@ class EventPublisher {
|
|
|
312
312
|
}
|
|
313
313
|
|
|
314
314
|
class SequentialIdGenerator {
|
|
315
|
-
|
|
315
|
+
nextId = 0;
|
|
316
316
|
generate() {
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
317
|
+
if (this.nextId === Number.MAX_SAFE_INTEGER) {
|
|
318
|
+
this.nextId = 0;
|
|
319
|
+
return Number.MAX_SAFE_INTEGER;
|
|
320
|
+
}
|
|
321
|
+
return this.nextId++;
|
|
320
322
|
}
|
|
321
323
|
}
|
|
322
324
|
|