claude
This commit is contained in:
parent
39c5591d36
commit
35877b69da
94 changed files with 3157 additions and 1859 deletions
|
|
@ -43,7 +43,9 @@ export class EventListeners<TListener extends (...args: any[]) => any> {
|
|||
const snapshot = this.listeners.slice();
|
||||
for (const listener of snapshot) {
|
||||
// allow removing listeners during the trigger loop
|
||||
if (!this.listeners.includes(listener)) {continue;}
|
||||
if (!this.listeners.includes(listener)) {
|
||||
continue;
|
||||
}
|
||||
listener(...args);
|
||||
}
|
||||
}
|
||||
|
|
@ -59,7 +61,9 @@ export class EventListeners<TListener extends (...args: any[]) => any> {
|
|||
const snapshot = this.listeners.slice();
|
||||
const promises: Promise<unknown>[] = [];
|
||||
for (const listener of snapshot) {
|
||||
if (!this.listeners.includes(listener)) {continue;}
|
||||
if (!this.listeners.includes(listener)) {
|
||||
continue;
|
||||
}
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
||||
const result = listener(...args);
|
||||
if (result instanceof Promise) {
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
export class MinCovered {
|
||||
private seenValues: number[] = [];
|
||||
|
||||
public constructor(private minValue: number) { }
|
||||
public constructor(private minValue: number) {}
|
||||
|
||||
public get min(): number {
|
||||
return this.minValue;
|
||||
|
|
|
|||
|
|
@ -10,5 +10,8 @@ export async function findMatchingFile(
|
|||
return undefined;
|
||||
}
|
||||
|
||||
return candidates.find((record) => record.remoteHash === contentHash);
|
||||
return candidates.find(
|
||||
(record) =>
|
||||
record.remoteHash !== undefined && record.remoteHash === contentHash
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,11 @@
|
|||
export async function hash(content: Uint8Array): Promise<string> {
|
||||
const digest = await crypto.subtle.digest(
|
||||
"SHA-256",
|
||||
content as Uint8Array<ArrayBuffer>
|
||||
);
|
||||
// Re-wrap into a fresh Uint8Array<ArrayBuffer> so SubtleCrypto's
|
||||
// BufferSource overload accepts it without an unsafe type assertion.
|
||||
// The lib types require an ArrayBuffer-backed view; the source may
|
||||
// be backed by SharedArrayBuffer in some runtimes.
|
||||
const buffer = new ArrayBuffer(content.byteLength);
|
||||
new Uint8Array(buffer).set(content);
|
||||
const digest = await crypto.subtle.digest("SHA-256", buffer);
|
||||
const bytes = new Uint8Array(digest);
|
||||
return Array.from(bytes, (b) => b.toString(16).padStart(2, "0")).join("");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
import { awaitAll } from "./await-all";
|
||||
import { sleep } from "./sleep";
|
||||
|
||||
/**
|
||||
|
|
@ -52,10 +53,7 @@ export function rateLimit<
|
|||
? minIntervalMs()
|
||||
: minIntervalMs;
|
||||
const fnPromise = fn(...args);
|
||||
running = Promise.all([
|
||||
fnPromise.catch(() => undefined),
|
||||
sleep(interval)
|
||||
]);
|
||||
running = awaitAll([fnPromise.catch(() => undefined), sleep(interval)]);
|
||||
return fnPromise;
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue