@atproto/common 0.0.1 → 0.1.1
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/async.d.ts +24 -0
- package/dist/check.d.ts +13 -4
- package/dist/index.d.ts +3 -1
- package/dist/index.js +351 -196
- package/dist/index.js.map +4 -4
- package/dist/ipld.d.ts +10 -0
- package/dist/src/check.d.ts +9 -0
- package/dist/src/cid.d.ts +2 -0
- package/dist/src/index.d.ts +8 -0
- package/dist/src/ipld.d.ts +10 -0
- package/dist/src/logger.d.ts +2 -0
- package/dist/src/network/names.d.ts +6 -0
- package/dist/src/network/uri.d.ts +20 -0
- package/dist/src/network/util.d.ts +9 -0
- package/dist/src/streams.d.ts +14 -0
- package/dist/src/tid.d.ts +20 -0
- package/dist/src/types.d.ts +14 -0
- package/dist/src/util.d.ts +9 -0
- package/dist/times.d.ts +4 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -0
- package/dist/types.d.ts +13 -9
- package/dist/util.d.ts +6 -1
- package/package.json +1 -1
- package/src/async.ts +100 -0
- package/src/check.ts +13 -4
- package/src/index.ts +3 -1
- package/src/ipld.ts +48 -0
- package/src/times.ts +4 -0
- package/src/types.ts +30 -31
- package/src/util.ts +34 -1
- package/tests/async.test.ts +22 -0
- package/tsconfig.build.tsbuildinfo +1 -1
- package/src/blocks.ts +0 -40
- /package/dist/{blocks.d.ts → src/blocks.d.ts} +0 -0
package/dist/async.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export declare const readFromGenerator: <T>(gen: AsyncGenerator<T, any, unknown>, maxLength?: number, timeout?: number) => Promise<T[]>;
|
|
2
|
+
export declare type Deferrable = {
|
|
3
|
+
resolve: () => void;
|
|
4
|
+
complete: Promise<void>;
|
|
5
|
+
};
|
|
6
|
+
export declare const createDeferrable: () => Deferrable;
|
|
7
|
+
export declare const createDeferrables: (count: number) => Deferrable[];
|
|
8
|
+
export declare const allComplete: (deferrables: Deferrable[]) => Promise<void>;
|
|
9
|
+
export declare class AsyncBuffer<T> {
|
|
10
|
+
maxSize?: number | undefined;
|
|
11
|
+
private buffer;
|
|
12
|
+
private promise;
|
|
13
|
+
private resolve;
|
|
14
|
+
constructor(maxSize?: number | undefined);
|
|
15
|
+
get curr(): T[];
|
|
16
|
+
get size(): number;
|
|
17
|
+
resetPromise(): void;
|
|
18
|
+
push(item: T): void;
|
|
19
|
+
pushMany(items: T[]): void;
|
|
20
|
+
events(): AsyncGenerator<T>;
|
|
21
|
+
}
|
|
22
|
+
export declare class AsyncBufferFullError extends Error {
|
|
23
|
+
constructor(maxSize: number);
|
|
24
|
+
}
|
package/dist/check.d.ts
CHANGED
|
@@ -1,9 +1,18 @@
|
|
|
1
|
-
|
|
1
|
+
import { ZodError } from 'zod';
|
|
2
|
+
export interface Checkable<T> {
|
|
2
3
|
parse: (obj: unknown) => T;
|
|
3
4
|
safeParse: (obj: unknown) => {
|
|
4
|
-
success:
|
|
5
|
+
success: true;
|
|
6
|
+
data: T;
|
|
7
|
+
} | {
|
|
8
|
+
success: false;
|
|
9
|
+
error: ZodError;
|
|
5
10
|
};
|
|
6
11
|
}
|
|
7
|
-
export
|
|
8
|
-
|
|
12
|
+
export interface Def<T> {
|
|
13
|
+
name: string;
|
|
14
|
+
schema: Checkable<T>;
|
|
15
|
+
}
|
|
16
|
+
export declare const is: <T>(obj: unknown, def: Checkable<T>) => obj is T;
|
|
17
|
+
export declare const assure: <T>(def: Checkable<T>, obj: unknown) => T;
|
|
9
18
|
export declare const isObject: (obj: unknown) => obj is Record<string, unknown>;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
export * as check from './check';
|
|
2
2
|
export * as util from './util';
|
|
3
|
+
export * from './async';
|
|
3
4
|
export * from './util';
|
|
4
5
|
export * from './tid';
|
|
5
|
-
export * from './
|
|
6
|
+
export * from './ipld';
|
|
6
7
|
export * from './logger';
|
|
7
8
|
export * from './types';
|
|
8
9
|
export * from './streams';
|
|
10
|
+
export * from './times';
|