Skip to content

Commit

Permalink
teehee
Browse files Browse the repository at this point in the history
  • Loading branch information
emmerich committed Apr 13, 2024
1 parent ceb43c7 commit 9199660
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
6 changes: 1 addition & 5 deletions src/components/DocumentView/CodeBlock/highlight.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,6 @@ export async function highlight(block: DocumentBlockCode): Promise<HighlightLine
return plainHighlighting(block);
}

if (block.key === 'dc6e6efdb1ed4981b71d5d3b02087996') {
return plainHighlighting(block);
}

// lineCount += block.nodes.length;
// if (lineCount > LINE_LIMIT) {
// // Too many lines and we risk crashing the worker, fallback to plain highlighting
Expand All @@ -71,7 +67,7 @@ export async function highlight(block: DocumentBlockCode): Promise<HighlightLine
return a.start - b.start;
});

const highlighter = await loadHighlighter();
const highlighter = await loadHighlighter(tokenCount > 4000);
await loadHighlighterLanguage(highlighter, langName);
lineCount += block.nodes.length;

Expand Down
6 changes: 3 additions & 3 deletions src/lib/async.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,13 +227,13 @@ const UndefinedSymbol = Symbol('Undefined');
* Wrap a singleton operation in a safe way for Cloudflare worker
* where I/O cannot be performed on behalf of a different request.
*/
export function singleton<R>(execute: () => Promise<R>): () => Promise<R> {
export function singleton<R>(execute: () => Promise<R>): (force?: boolean) => Promise<R> {
let cachedResult: Promise<R> | typeof UndefinedSymbol = UndefinedSymbol;
const states = new WeakMap<object, Promise<R>>();

return async () => {
return async (force) => {
// console.log('cachedResult', cachedResult === UndefinedSymbol);
if (cachedResult !== UndefinedSymbol) {
if (!force && cachedResult !== UndefinedSymbol) {
// Result is actually shared between requests
return cachedResult;
}
Expand Down

0 comments on commit 9199660

Please sign in to comment.