@pistonite/pure 0.27.0 → 0.28.0
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/package.json +2 -2
- package/src/fs/FsFile.ts +1 -1
- package/src/fs/FsFileImpl.ts +5 -11
- package/src/fs/FsFileStandaloneImplHandleAPI.ts +3 -9
- package/src/fs/FsFileSystemInternal.ts +1 -1
- package/src/fs/FsImplEntryAPI.ts +12 -48
- package/src/fs/FsImplFileAPI.ts +3 -12
- package/src/fs/FsImplHandleAPI.ts +13 -48
- package/src/fs/FsOpen.ts +27 -71
- package/src/fs/FsOpenFile.ts +2 -7
- package/src/fs/FsSave.ts +4 -11
- package/src/fs/FsSupportStatus.ts +1 -5
- package/src/fs/index.ts +2 -11
- package/src/log/index.ts +1 -5
- package/src/log/logger.ts +2 -6
- package/src/memory/async_erc.ts +4 -9
- package/src/memory/cell.ts +2 -8
- package/src/memory/erc.test.ts +123 -126
- package/src/memory/erc.ts +3 -8
- package/src/memory/persist.ts +1 -4
- package/src/pref/device.ts +3 -12
- package/src/pref/locale.ts +6 -18
- package/src/result/index.ts +1 -3
- package/src/sync/batch.test.ts +4 -6
- package/src/sync/batch.ts +4 -21
- package/src/sync/capture.ts +1 -4
- package/src/sync/debounce.ts +1 -6
- package/src/sync/latest.ts +2 -12
- package/src/sync/serial.test.ts +1 -2
- package/src/sync/serial.ts +3 -12
- package/src/sync/util.ts +1 -3
package/src/sync/serial.test.ts
CHANGED
|
@@ -5,8 +5,7 @@ import type { Result } from "../result/index.ts";
|
|
|
5
5
|
|
|
6
6
|
test("example", async () => {
|
|
7
7
|
// helper function to simulate async work
|
|
8
|
-
const wait = (ms: number) =>
|
|
9
|
-
new Promise((resolve) => setTimeout(resolve, ms));
|
|
8
|
+
const wait = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
10
9
|
// Create the wrapped function
|
|
11
10
|
const doWork = serial({
|
|
12
11
|
fn: (checkCancel) => async () => {
|
package/src/sync/serial.ts
CHANGED
|
@@ -133,10 +133,7 @@ import type { AnyFn } from "./util.ts";
|
|
|
133
133
|
* If the underlying function throws, the exception will be re-thrown to the caller.
|
|
134
134
|
*/
|
|
135
135
|
|
|
136
|
-
export function serial<TFn extends AnyFn>({
|
|
137
|
-
fn,
|
|
138
|
-
onCancel,
|
|
139
|
-
}: SerialConstructor<TFn>) {
|
|
136
|
+
export function serial<TFn extends AnyFn>({ fn, onCancel }: SerialConstructor<TFn>) {
|
|
140
137
|
const impl = new SerialImpl(fn, onCancel);
|
|
141
138
|
return (...args: Parameters<TFn>) => impl.invoke(...args);
|
|
142
139
|
}
|
|
@@ -162,10 +159,7 @@ class SerialImpl<TFn extends AnyFn> {
|
|
|
162
159
|
private fn: SerialFnCreator<TFn>;
|
|
163
160
|
private onCancel: SerialEventCancelCallback;
|
|
164
161
|
|
|
165
|
-
constructor(
|
|
166
|
-
fn: SerialFnCreator<TFn>,
|
|
167
|
-
onCancel?: SerialEventCancelCallback,
|
|
168
|
-
) {
|
|
162
|
+
constructor(fn: SerialFnCreator<TFn>, onCancel?: SerialEventCancelCallback) {
|
|
169
163
|
this.fn = fn;
|
|
170
164
|
this.serial = 0n;
|
|
171
165
|
if (onCancel) {
|
|
@@ -212,10 +206,7 @@ type SerialFnCreator<T> = (checkCancel: CheckCancelFn, serial: SerialId) => T;
|
|
|
212
206
|
* The callback type passed to SerialEvent constructor to be called
|
|
213
207
|
* when the event is cancelled
|
|
214
208
|
*/
|
|
215
|
-
export type SerialEventCancelCallback = (
|
|
216
|
-
current: SerialId,
|
|
217
|
-
latest: SerialId,
|
|
218
|
-
) => void;
|
|
209
|
+
export type SerialEventCancelCallback = (current: SerialId, latest: SerialId) => void;
|
|
219
210
|
|
|
220
211
|
/** The error type received by caller when an event is cancelled */
|
|
221
212
|
export type SerialCancelToken = "cancel";
|
package/src/sync/util.ts
CHANGED
|
@@ -26,9 +26,7 @@ export type PromiseHandle<T> = {
|
|
|
26
26
|
|
|
27
27
|
/** Shorthand for Awaited<ReturnType<T>> */
|
|
28
28
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
29
|
-
export type AwaitRet<T> = T extends (...args: any[]) => infer R
|
|
30
|
-
? Awaited<R>
|
|
31
|
-
: never;
|
|
29
|
+
export type AwaitRet<T> = T extends (...args: any[]) => infer R ? Awaited<R> : never;
|
|
32
30
|
|
|
33
31
|
/** Type for any function */
|
|
34
32
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|