Repository navigation
docs: enhance README with examples, comparison table, and migration guides #63
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,9 @@ | ||
| # zflate | ||
|
|
||
| [](https://www.npmjs.com/package/zflate) | ||
| [](https://www.npmjs.com/package/zflate) | ||
| [](https://github.com/derodero24/zflate/actions/workflows/ci.yml) | ||
| [](https://codecov.io/gh/derodero24/zflate) | ||
| [](LICENSE) | ||
|
|
||
| Rust-powered universal compression for JavaScript/TypeScript. **zstd**, **gzip**, and **brotli** in one package. | ||
|
|
@@ -44,6 +46,22 @@ const compressed = zstdCompress(data); | |
| const decompressed = zstdDecompress(compressed); | ||
| ``` | ||
|
|
||
| ```typescript | ||
| // Gzip | ||
| import { gzipCompress, gzipDecompress } from 'zflate'; | ||
|
|
||
| const compressed = gzipCompress(Buffer.from('Hello, gzip!')); | ||
| const decompressed = gzipDecompress(compressed); | ||
| ``` | ||
|
|
||
| ```typescript | ||
| // Brotli | ||
| import { brotliCompress, brotliDecompress } from 'zflate'; | ||
|
|
||
| const compressed = brotliCompress(Buffer.from('Hello, brotli!')); | ||
| const decompressed = brotliDecompress(compressed); | ||
| ``` | ||
|
Comment on lines
+49
to
+63
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Quick Start が「4アルゴリズム掲載」の基準を満たしていません。 zstd/gzip/brotli はありますが、deflate の one-shot 例が未掲載です。受け入れ基準に合わせて deflate 例も追加した方がよいです。 🤖 Prompt for AI Agents |
||
|
|
||
| ### Streaming | ||
|
|
||
| ```typescript | ||
|
|
@@ -147,6 +165,64 @@ zstdCompress(data, -1); | |
|
|
||
| `x86_64-apple-darwin`, `aarch64-apple-darwin`, `x86_64-unknown-linux-gnu`, `x86_64-unknown-linux-musl`, `aarch64-unknown-linux-gnu`, `aarch64-unknown-linux-musl`, `x86_64-pc-windows-msvc`, `aarch64-pc-windows-msvc` | ||
|
|
||
| ## Browser Usage | ||
|
|
||
| zflate works in browsers via WASM. Use a bundler like Vite, webpack, or esbuild, or import directly from a CDN: | ||
|
|
||
| ```typescript | ||
| import { gzipCompress, gzipDecompress } from 'zflate'; | ||
|
|
||
| const encoder = new TextEncoder(); | ||
| const data = encoder.encode('Hello from the browser!'); | ||
|
|
||
| const compressed = gzipCompress(data); | ||
| const decompressed = gzipDecompress(compressed); | ||
| ``` | ||
|
|
||
| > Note: WASM initialization happens automatically on first use. For performance-critical applications, consider warming up the module by calling any function once during app startup. | ||
|
|
||
|
Comment on lines
+168
to
+183
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Browser/WASM セクションに必須情報が不足しています。 目的にある「CDN import 例」と「WASM 最適化バンドルサイズの明記」が不足しています。現状は説明文のみなので、実コード例とサイズ情報(目安値)を追記してください。 🤖 Prompt for AI Agents |
||
| ## Comparison with Alternatives | ||
|
|
||
| | Feature | zflate | pako | fflate | node:zlib | | ||
| |---------|--------|------|--------|-----------| | ||
| | zstd | ✅ | ❌ | ❌ | ✅* | | ||
| | gzip/deflate | ✅ | ✅ | ✅ | ✅ | | ||
| | brotli | ✅ | ❌ | ❌ | ✅ | | ||
| | Web Streams API | ✅ | ❌ | ❌ | ❌ | | ||
| | Streaming | ✅ | ✅† | ✅ | ✅ | | ||
| | Browser | ✅ | ✅ | ✅ | ❌ | | ||
| | Deno/Bun | ✅ | ✅ | ✅ | ❌ | | ||
| | Native performance | ✅ | ❌ | ❌ | ✅ | | ||
| | TypeScript | ✅ | ✅ | ✅ | ✅ | | ||
| | Zero JS deps | ✅ | ✅ | ✅ | ✅ | | ||
|
|
||
| \* Node.js ≥ 22.15 (experimental) | ||
| † Chunked mode via `Inflate`/`Deflate` classes, not Web Streams API | ||
|
Comment on lines
+188
to
+200
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🌐 Web query:
💡 Result: Node.jsの公式ドキュメントによると、node:zlibモジュールのZstandard(zstd)対応はzstdCompressおよびzstdDecompress(およびストリーム版のcreateZstdCompress/createZstdDecompress)が利用可能で、初回導入バージョンはv23.8.0およびv22.15.0です。安定性はexperimental(Stability: 1 - Experimental)です。 該当APIリファレンスURL: https://nodejs.org/api/zlib.html Citations:
Node.js公式ドキュメントでzstd対応を確認し、リンク付きで明記してください。
🤖 Prompt for AI Agents |
||
|
|
||
| ## Migration | ||
|
|
||
| ### From pako | ||
|
|
||
| ```diff | ||
| - import pako from 'pako'; | ||
| - const compressed = pako.gzip(data); | ||
| - const decompressed = pako.ungzip(compressed); | ||
| + import { gzipCompress, gzipDecompress } from 'zflate'; | ||
| + const compressed = gzipCompress(data); | ||
| + const decompressed = gzipDecompress(compressed); | ||
| ``` | ||
|
|
||
| ### From node:zlib | ||
|
|
||
| ```diff | ||
| - import { gzipSync, gunzipSync } from 'node:zlib'; | ||
| - const compressed = gzipSync(data); | ||
| - const decompressed = gunzipSync(compressed); | ||
| + import { gzipCompress, gzipDecompress } from 'zflate'; | ||
| + const compressed = gzipCompress(data); | ||
| + const decompressed = gzipDecompress(compressed); | ||
| ``` | ||
|
|
||
| ## Benchmarks | ||
|
|
||
| Measured on Apple M1, Node.js v22 (zstd level 3, gzip/brotli level 6): | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
受け入れ基準の「bundle size バッジ」が未反映です。
バッジ追加は進んでいますが、issue
#47の目的にある bundle size バッジが見当たりません。README 冒頭に追加してください。🤖 Prompt for AI Agents