@standardserver/shared 0.0.5 → 0.0.7
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 +7 -4
- package/dist/index.d.ts +7 -4
- package/dist/index.mjs +21 -3
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
declare function toArray<T>(value: T): T extends readonly any[] ? T : Exclude<T, undefined | null>[];
|
|
2
2
|
|
|
3
3
|
declare const PACKAGE_NAME = "@standardserver/shared";
|
|
4
|
-
declare const PACKAGE_VERSION = "0.0.
|
|
4
|
+
declare const PACKAGE_VERSION = "0.0.7";
|
|
5
5
|
/**
|
|
6
6
|
* Generates a unique symbol for the specified name within the package scope.
|
|
7
7
|
* The symbol is globally registered using `Symbol.for` to ensure consistency across modules.
|
|
@@ -65,7 +65,7 @@ declare function stringifyJSON<T>(value: T | {
|
|
|
65
65
|
/**
|
|
66
66
|
* Checks whether the provided container is a typescript object (object or function).
|
|
67
67
|
*/
|
|
68
|
-
declare function isTypescriptObject(maybeObject: unknown): maybeObject is object
|
|
68
|
+
declare function isTypescriptObject(maybeObject: unknown): maybeObject is object & Record<PropertyKey, unknown>;
|
|
69
69
|
|
|
70
70
|
interface GetOrBindOptions {
|
|
71
71
|
/**
|
|
@@ -106,12 +106,15 @@ declare class AsyncIdQueue<T> {
|
|
|
106
106
|
assertOpen(id: string): void;
|
|
107
107
|
}
|
|
108
108
|
|
|
109
|
+
interface SleepOptions {
|
|
110
|
+
signal?: AbortSignal | undefined;
|
|
111
|
+
}
|
|
109
112
|
/**
|
|
110
113
|
* sleep for a specified amount of time
|
|
111
114
|
*/
|
|
112
|
-
declare function sleep(ms: number): Promise<void>;
|
|
115
|
+
declare function sleep(ms: number, { signal }?: SleepOptions): Promise<void>;
|
|
113
116
|
|
|
114
117
|
declare function tryDecodeURIComponent(value: string): string;
|
|
115
118
|
|
|
116
119
|
export { AbortError, AsyncIdQueue, AsyncIteratorClass, PACKAGE_NAME, PACKAGE_VERSION, SequentialIdGenerator, getOrBind, getPackageSymbol, isAsyncIteratorObject, isTypescriptObject, parseEmptyableJSON, sequential, sleep, stringifyJSON, toArray, tryDecodeURIComponent };
|
|
117
|
-
export type { AsyncCleanupFn, AsyncIdQueueCloseOptions, AsyncIdQueueOptions, AsyncIteratorClassNextFn, GetOrBindOptions };
|
|
120
|
+
export type { AsyncCleanupFn, AsyncIdQueueCloseOptions, AsyncIdQueueOptions, AsyncIteratorClassNextFn, GetOrBindOptions, SleepOptions };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
declare function toArray<T>(value: T): T extends readonly any[] ? T : Exclude<T, undefined | null>[];
|
|
2
2
|
|
|
3
3
|
declare const PACKAGE_NAME = "@standardserver/shared";
|
|
4
|
-
declare const PACKAGE_VERSION = "0.0.
|
|
4
|
+
declare const PACKAGE_VERSION = "0.0.7";
|
|
5
5
|
/**
|
|
6
6
|
* Generates a unique symbol for the specified name within the package scope.
|
|
7
7
|
* The symbol is globally registered using `Symbol.for` to ensure consistency across modules.
|
|
@@ -65,7 +65,7 @@ declare function stringifyJSON<T>(value: T | {
|
|
|
65
65
|
/**
|
|
66
66
|
* Checks whether the provided container is a typescript object (object or function).
|
|
67
67
|
*/
|
|
68
|
-
declare function isTypescriptObject(maybeObject: unknown): maybeObject is object
|
|
68
|
+
declare function isTypescriptObject(maybeObject: unknown): maybeObject is object & Record<PropertyKey, unknown>;
|
|
69
69
|
|
|
70
70
|
interface GetOrBindOptions {
|
|
71
71
|
/**
|
|
@@ -106,12 +106,15 @@ declare class AsyncIdQueue<T> {
|
|
|
106
106
|
assertOpen(id: string): void;
|
|
107
107
|
}
|
|
108
108
|
|
|
109
|
+
interface SleepOptions {
|
|
110
|
+
signal?: AbortSignal | undefined;
|
|
111
|
+
}
|
|
109
112
|
/**
|
|
110
113
|
* sleep for a specified amount of time
|
|
111
114
|
*/
|
|
112
|
-
declare function sleep(ms: number): Promise<void>;
|
|
115
|
+
declare function sleep(ms: number, { signal }?: SleepOptions): Promise<void>;
|
|
113
116
|
|
|
114
117
|
declare function tryDecodeURIComponent(value: string): string;
|
|
115
118
|
|
|
116
119
|
export { AbortError, AsyncIdQueue, AsyncIteratorClass, PACKAGE_NAME, PACKAGE_VERSION, SequentialIdGenerator, getOrBind, getPackageSymbol, isAsyncIteratorObject, isTypescriptObject, parseEmptyableJSON, sequential, sleep, stringifyJSON, toArray, tryDecodeURIComponent };
|
|
117
|
-
export type { AsyncCleanupFn, AsyncIdQueueCloseOptions, AsyncIdQueueOptions, AsyncIteratorClassNextFn, GetOrBindOptions };
|
|
120
|
+
export type { AsyncCleanupFn, AsyncIdQueueCloseOptions, AsyncIdQueueOptions, AsyncIteratorClassNextFn, GetOrBindOptions, SleepOptions };
|
package/dist/index.mjs
CHANGED
|
@@ -3,7 +3,7 @@ function toArray(value) {
|
|
|
3
3
|
}
|
|
4
4
|
|
|
5
5
|
const PACKAGE_NAME = "@standardserver/shared";
|
|
6
|
-
const PACKAGE_VERSION = "0.0.
|
|
6
|
+
const PACKAGE_VERSION = "0.0.7";
|
|
7
7
|
function getPackageSymbol(name) {
|
|
8
8
|
return Symbol.for(`${PACKAGE_NAME}@${PACKAGE_VERSION}/${name}`);
|
|
9
9
|
}
|
|
@@ -226,8 +226,26 @@ class AsyncIdQueue {
|
|
|
226
226
|
}
|
|
227
227
|
}
|
|
228
228
|
|
|
229
|
-
function sleep(ms) {
|
|
230
|
-
return new Promise((resolve) =>
|
|
229
|
+
function sleep(ms, { signal } = {}) {
|
|
230
|
+
return new Promise((resolve, reject) => {
|
|
231
|
+
if (signal?.aborted) {
|
|
232
|
+
reject(signal.reason);
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
235
|
+
let abortListener = null;
|
|
236
|
+
const timeout = setTimeout(() => {
|
|
237
|
+
if (abortListener) {
|
|
238
|
+
signal?.removeEventListener("abort", abortListener);
|
|
239
|
+
}
|
|
240
|
+
resolve();
|
|
241
|
+
}, ms);
|
|
242
|
+
if (signal) {
|
|
243
|
+
signal.addEventListener("abort", abortListener = () => {
|
|
244
|
+
clearTimeout(timeout);
|
|
245
|
+
reject(signal?.reason);
|
|
246
|
+
}, { once: true });
|
|
247
|
+
}
|
|
248
|
+
});
|
|
231
249
|
}
|
|
232
250
|
|
|
233
251
|
function tryDecodeURIComponent(value) {
|