`title: Compression Streams Brotli 支持检测与回退封装``categories: Web 开发/前端/数据管理``keywords: Compression Streams,Brotli,GZIP,检测,回退``description: 检测 Compression Streams 的 Brotli 支持并封装回退实现,在浏览器端对数据进行兼容压缩处理与持久化。`封装示例function hasBrotli() { try { new CompressionStream('br'); return true; } catch { return false; } } async function compressStream(stream, alg = 'gzip') { if (alg === 'br' && hasBrotli()) return stream.pipeThrough(new CompressionStream('br')); return stream.pipeThrough(new CompressionStream('gzip')); }

发表评论 取消回复