-
Notifications
You must be signed in to change notification settings - Fork 712
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replaced fetch() with direct data access
- Loading branch information
1 parent
906e988
commit 8ca7290
Showing
8 changed files
with
48 additions
and
46 deletions.
There are no files selected for viewing
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
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
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
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
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
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
15 changes: 15 additions & 0 deletions
15
src/lib/output/themes/default/assets/typedoc/utils/decompress.ts
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/** | ||
* Decompresses Base64-encoded Gzip data and parses it into a JSON object. | ||
* | ||
* @param base64 - The Base64-encoded string representing the Gzip-compressed JSON string. | ||
* @returns A promise that resolves to the parsed JSON object. | ||
*/ | ||
export async function decompressJson(base64: string) { | ||
const binaryData = Uint8Array.from(atob(base64), (c) => c.charCodeAt(0)); | ||
const blob = new Blob([binaryData]); | ||
const decompressedStream = blob | ||
.stream() | ||
.pipeThrough(new DecompressionStream("gzip")); | ||
const decompressedText = await new Response(decompressedStream).text(); | ||
return JSON.parse(decompressedText); | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { gzip } from "zlib"; | ||
import { promisify } from "util"; | ||
|
||
const gzipP = promisify(gzip); | ||
|
||
/** | ||
* Compresses a JSON-serializable object into a Base64-encoded Gzip string. | ||
* | ||
* @param data - The JSON-serializable object to compress. | ||
* @returns A promise that resolves to a Base64-encoded string of the Gzip-compressed data. | ||
*/ | ||
export async function compressJson(data: any) { | ||
const gz = await gzipP(Buffer.from(JSON.stringify(data))); | ||
return gz.toString("base64"); | ||
} |