前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >node zlib压缩模块了解一下

node zlib压缩模块了解一下

作者头像
马克社区
发布2022-06-15 17:02:04
6800
发布2022-06-15 17:02:04
举报
文章被收录于专栏:高端IT

压缩:

从index.html压缩成index.html.gz

const zlib = require(‘zlib’);

const gzip = zlib.createGzip(); const fs = require(‘fs’); const inp = fs.createReadStream(‘index.html’); const out = fs.createWriteStream(‘index.html.gz’);

inp.pipe(gzip) .on(‘error’, () => { // 处理错误 }) .pipe(out) .on(‘error’, () => { // 处理错误 });

解压:

从index.html.gz解压为index.html

const zlib = require(‘zlib’);

const gzip = zlib.createGzip(); const fs = require(‘fs’); const inp = fs.createReadStream(‘index.html.gz’); const out = fs.createWriteStream(‘index.html’);

inp.pipe(gzip)

更多内容请见原文,原文转载自:https://blog.csdn.net/weixin_44519496/article/details/119836266

本文系转载,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文系转载前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档