@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.
@@ -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 () => {
@@ -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