Skip to content

Commit 26383e5

Browse files
committed
init
1 parent d342d2b commit 26383e5

File tree

11 files changed

+93278
-0
lines changed

11 files changed

+93278
-0
lines changed

.github/workflows/ci.yml

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: ci
2+
3+
on:
4+
push:
5+
branches: [master]
6+
pull_request:
7+
branches: [master]
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- uses: actions/checkout@v2
15+
- name: Install Deno
16+
uses: denolib/setup-deno@master
17+
with:
18+
deno-version: 1.0.3
19+
20+
- name: Test
21+
run: deno test ./test.ts

.gitignore

+5
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,8 @@ Cargo.lock
88

99
# These are backup files generated by rustfmt
1010
**/*.rs.bk
11+
12+
13+
#Added by cargo
14+
15+
/target

.vscode/settings.json

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"deno.enable": true
3+
}

Cargo.toml

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
[package]
2+
name = "wasm_gzip"
3+
version = "0.1.0"
4+
authors = ["Enok <416828041@qq.com>"]
5+
edition = "2018"
6+
7+
[lib]
8+
crate-type = ["cdylib", "rlib"]
9+
10+
[dependencies]
11+
wasm-bindgen = "0.2.62"
12+
flate2 = "1.0.14"
13+
wee_alloc = { version = "0.4.5" }
14+
15+
[profile.release]
16+
opt-level = 'z'
17+
lto = true

README.md

+20
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,22 @@
11
# wasm_gzip
2+
23
Gzip encryption and decryption wasm implementation, support Deno
4+
5+
[![Build Status](https://github.com/manyuanrong/deno-smtp/workflows/ci/badge.svg?branch=master)](https://github.com/manyuanrong/wasm_gzip/actions)
6+
![GitHub](https://img.shields.io/github/license/manyuanrong/wasm_gzip.svg)
7+
![GitHub release](https://img.shields.io/github/release/manyuanrong/wasm_gzip.svg)
8+
![(Deno)](https://img.shields.io/badge/deno-1.0.2-green.svg)
9+
10+
## Useage
11+
12+
```ts
13+
import {
14+
gzipDecode,
15+
gzipEncode,
16+
} from "https://github.com/manyuanrong/wasm_gzip/raw/master/mod.ts";
17+
18+
const helloWorld = new TextEncoder().encode("Hello World");
19+
20+
const encoded = gzipEncode(helloWorld);
21+
const decoded = gzipDecode(encoded);
22+
```

build.ts

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
const cargoBuild = Deno.run({
2+
cmd: ["wasm-pack", "build", "-t", "web", "--release"],
3+
stdout: "inherit",
4+
});
5+
6+
await cargoBuild.status();
7+
8+
const wasmBin = await Deno.readFile("./pkg/wasm_gzip_bg.wasm");
9+
10+
const bytes: number[] = [];
11+
12+
wasmBin.forEach((byte) => bytes.push(byte));
13+
14+
await Deno.writeTextFile(
15+
"./bytes.js",
16+
`
17+
const code = [${bytes}];
18+
19+
const bytes = Uint8Array.from(code);
20+
21+
export default bytes;`,
22+
);
23+
24+
await Deno.copyFile("./pkg/wasm_gzip.js", "./wasm.js");

0 commit comments

Comments
 (0)