Skip to content

Commit

Permalink
chore: move schema/crypto/spec to platform
Browse files Browse the repository at this point in the history
  • Loading branch information
blakebyrnes committed Mar 1, 2024
1 parent c82fc6d commit 116880a
Show file tree
Hide file tree
Showing 108 changed files with 35 additions and 5,248 deletions.
22 changes: 16 additions & 6 deletions commons/lib/asyncUtils.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,25 @@
export function debounce(func: () => any, wait: number): () => void {
export function debounce<T extends (...args: any[]) => void | Promise<void>>(
func: T,
wait: number,
maxWait?: number,
): T {
let timeout: NodeJS.Timeout;
let lastRun: number;

return function runLater() {
return function runLater(...args: any[]) {
function later(): void {
timeout = undefined;
func();
void func(...args);
}

clearTimeout(timeout);
timeout = setTimeout(later, wait).unref();
};

if (maxWait && Date.now() - lastRun > maxWait) {
void func(...args);
} else {
timeout = setTimeout(later, wait).unref();
}
lastRun = Date.now();
} as T;
}

export function length(source: AsyncIterable<unknown>): Promise<number> {
Expand Down
15 changes: 15 additions & 0 deletions commons/lib/objectUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,18 @@ export function omit<T, Keys extends keyof T & string>(
}
return result;
}

export function pick<T, Keys extends keyof T & string>(
object: T,
keys: Keys[],
): Pick<T, Exclude<keyof T, Keys>> {
object = Object(object);
const result = {} as any;

for (const [key, value] of Object.entries(object)) {
if (keys.includes(key as any)) {
result[key] = value;
}
}
return result;
}
191 changes: 0 additions & 191 deletions crypto/CHANGELOG.md

This file was deleted.

6 changes: 0 additions & 6 deletions crypto/bin/cli.ts

This file was deleted.

Loading

0 comments on commit 116880a

Please sign in to comment.