This repository has been archived by the owner on Sep 14, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: compress ts formatter wasm (#1073)
- Loading branch information
Showing
6 changed files
with
35 additions
and
12 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 was deleted.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
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,17 @@ | ||
import { Buffer } from "../deps/std/streams.ts" | ||
|
||
export async function compress(data: Uint8Array) { | ||
const compressed = new Buffer() | ||
await new Buffer(data).readable | ||
.pipeThrough(new CompressionStream("gzip")) | ||
.pipeTo(compressed.writable) | ||
return compressed.bytes() | ||
} | ||
|
||
export async function decompress(data: Uint8Array) { | ||
const decompressed = new Buffer() | ||
await new Buffer(data).readable | ||
.pipeThrough(new DecompressionStream("gzip")) | ||
.pipeTo(decompressed.writable) | ||
return decompressed.bytes() | ||
} |
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 |
---|---|---|
@@ -1,7 +1,12 @@ | ||
import { createFromBuffer } from "../deps/dprint.ts" | ||
import dprintConfig from "../dprint.json" assert { type: "json" } | ||
import { tsFormatterWasm } from "./_artifacts/tsFormatterWasm.ts" | ||
import { tsFormatterWasmCompressed } from "./_artifacts/tsFormatterWasmCompressed.ts" | ||
import { decompress } from "./compression.ts" | ||
|
||
export const tsFormatter = createFromBuffer(tsFormatterWasm) | ||
const { indentWidth, lineWidth, typescript: config } = dprintConfig | ||
tsFormatter.setConfig({ indentWidth, lineWidth }, config) | ||
export const tsFormatterPromise = (async () => { | ||
const tsFormatterWasm = await decompress(tsFormatterWasmCompressed) | ||
const tsFormatter = createFromBuffer(tsFormatterWasm) | ||
const { indentWidth, lineWidth, typescript: config } = dprintConfig | ||
tsFormatter.setConfig({ indentWidth, lineWidth }, config) | ||
return tsFormatter | ||
})() |