This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface deferType<T> extends Promise<T> { | |
resolve: (value: T) => void, | |
reject: (reason?: any) => void, | |
}; | |
function defer<T>(): deferType<T> { | |
const data = {}; | |
return Object.assign(new Promise<T>((resolve, reject) => Object.assign(data, { resolve, reject })), data) as deferType<T>; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function throttle<T extends [...T], U>(callback: (...args: [...T]) => U, interval: number): (...args: [...T]) => void { | |
let enableCall = true; | |
return (...args: [...T]) => { | |
if (!enableCall) { | |
return; | |
} | |
enableCall = false; | |
callback(...args); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function debounce<T extends [...T], U>(callback: (...args: [...T]) => U, delayMs: number): (...args: [...T]) => void { | |
let timerId: any = null; | |
return (...args: [...T]) => { | |
clearTimeout(timerId); | |
timerId = setTimeout(() => callback(...args), delayMs); | |
}; | |
} | |
export { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { serve } from "https://deno.land/std@0.135.0/http/server.ts"; | |
import { create } from "https://deno.land/x/pkce_deno@v2.0/mod.ts"; | |
serve((req) => { | |
try { | |
const len = (new URL(req.url)).searchParams.get('length'); | |
const respData = (len ? create(+len) : create()); | |
return new Response(JSON.stringify({ | |
...respData, | |
}), { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const synth = window.speechSynthesis; | |
let currentReadoutStrings: string[] = []; | |
let currentAlertStrings: string[] = []; | |
let currentSSU: SpeechSynthesisUtterance; | |
function reset(): void { | |
currentReadoutStrings = []; | |
currentAlertStrings = []; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let handlers = []; | |
let keyListenerEnabled = false; | |
function addKeyListener() { | |
document.addEventListener('keydown', onKeyDown); | |
} | |
function onKeyDown(event: KeyboardEvent) { | |
for (let i = handlers.length - 1; i >= 0; i--) { | |
if (handlers[i] && handlers[i](event)) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useCallback, useState } from "react"; | |
export default function Image({ | |
src, | |
altText, | |
textClassName = "", | |
imageClassName = "" | |
}: { | |
src: string[] | string; | |
altText?: string; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function debounce(callback, delayMs) { | |
let timerId = null; | |
return function (...args) { | |
clearTimeout(timerId); | |
timerId = setTimeout(() => callback(...args), delayMs); | |
}; | |
} | |
export { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function throttle(callback, interval) { | |
let enableCall = true; | |
return function (...args) { | |
if (!enableCall) { | |
return; | |
} | |
enableCall = false; | |
callback(...args); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const backOffAlgorithms = {}; | |
const algorithms = { | |
EXPONENTIAL: 'exponential', | |
FIBONACCI: 'fibonacci', | |
LINEAR: 'linear', | |
STATIC: 'static' | |
}; | |
function create(options) { |
NewerOlder