Compare commits
1 Commits
Author | SHA1 | Date |
---|---|---|
yutent | 07aff737e0 |
|
@ -19,18 +19,18 @@ npm install @bytedo/gzip
|
||||||
|
|
||||||
```js
|
```js
|
||||||
|
|
||||||
import { gzip , ungzip } from '@bytedo/gzip' // use importmap
|
import { gzip , gunzip } from '@bytedo/gzip' // use importmap
|
||||||
// or
|
// or
|
||||||
import { gzip , ungzip } from '//jscdn.ink/@bytedo/gzip/latest/index.js'
|
import { gzip , gunzip } from '//jscdn.ink/@bytedo/gzip/latest/index.js'
|
||||||
|
|
||||||
// 也可以单独引入
|
// 也可以单独引入
|
||||||
import { gzip } from '//jscdn.ink/@bytedo/gzip/latest/gzip.js'
|
import { gzip } from '//jscdn.ink/@bytedo/gzip/latest/gzip.js'
|
||||||
import { ungzip } from '//jscdn.ink/@bytedo/gzip/latest/ungzip.js'
|
import { gunzip } from '//jscdn.ink/@bytedo/gzip/latest/gunzip.js'
|
||||||
|
|
||||||
|
|
||||||
let base64Str = gzip('hello world') // return base64 string
|
let base64Str = gzip('hello world') // return base64 string
|
||||||
|
|
||||||
let txt = ungzip(base64Str) // return hello world
|
let txt = gunzip(base64Str) // return hello world
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
@ -2,10 +2,10 @@
|
||||||
"name": "@bytedo/gzip",
|
"name": "@bytedo/gzip",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"description": "浏览器端的gzip库, fork于pako, 仅调整语法为esm, 并只保留gzip的导出。",
|
"description": "浏览器端的gzip库, fork于pako, 仅调整语法为esm, 并只保留gzip的导出。",
|
||||||
"version": "2.1.0",
|
"version": "2.1.1",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"gzip",
|
"gzip",
|
||||||
"ungzip"
|
"gunzip"
|
||||||
],
|
],
|
||||||
"files": [
|
"files": [
|
||||||
"dist/*"
|
"dist/*"
|
||||||
|
@ -16,9 +16,9 @@
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build:gzip": "esbuild src/gzip.js --minify --bundle --format=esm --target=esnext --outfile=dist/gzip.js",
|
"build:gzip": "esbuild src/gzip.js --minify --bundle --format=esm --target=esnext --outfile=dist/gzip.js",
|
||||||
"build:ungzip": "esbuild src/ungzip.js --minify --bundle --format=esm --target=esnext --outfile=dist/ungzip.js",
|
"build:gunzip": "esbuild src/gunzip.js --minify --bundle --format=esm --target=esnext --outfile=dist/gunzip.js",
|
||||||
"build:all": "esbuild src/index.js --format=esm --outfile=dist/index.js",
|
"build:all": "esbuild src/index.js --format=esm --outfile=dist/index.js",
|
||||||
"build": "npm run build:gzip && npm run build:ungzip && npm run build:all"
|
"build": "npm run build:gzip && npm run build:gunzip && npm run build:all"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"esbuild": "^0.17.16"
|
"esbuild": "^0.17.16"
|
||||||
|
|
|
@ -356,9 +356,9 @@ Inflate.prototype.onEnd = function (status) {
|
||||||
* - data (Uint8Array|ArrayBuffer): input data to decompress.
|
* - data (Uint8Array|ArrayBuffer): input data to decompress.
|
||||||
* - options (Object): zlib inflate options.
|
* - options (Object): zlib inflate options.
|
||||||
*
|
*
|
||||||
* Decompress `data` with inflate/ungzip and `options`. Autodetect
|
* Decompress `data` with inflate/gunzip and `options`. Autodetect
|
||||||
* format via wrapper header by default. That's why we don't provide
|
* format via wrapper header by default. That's why we don't provide
|
||||||
* separate `ungzip` method.
|
* separate `gunzip` method.
|
||||||
*
|
*
|
||||||
* Supported options are:
|
* Supported options are:
|
||||||
*
|
*
|
||||||
|
@ -390,7 +390,7 @@ Inflate.prototype.onEnd = function (status) {
|
||||||
* }
|
* }
|
||||||
* ```
|
* ```
|
||||||
**/
|
**/
|
||||||
function ungzip(input, options) {
|
function gunzip(input, options) {
|
||||||
const inflator = new Inflate(options)
|
const inflator = new Inflate(options)
|
||||||
|
|
||||||
inflator.push(base642buf(input))
|
inflator.push(base642buf(input))
|
||||||
|
@ -402,7 +402,7 @@ function ungzip(input, options) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ungzip(data[, options]) -> Uint8Array|String
|
* gunzip(data[, options]) -> Uint8Array|String
|
||||||
* - data (Uint8Array|ArrayBuffer): input data to decompress.
|
* - data (Uint8Array|ArrayBuffer): input data to decompress.
|
||||||
* - options (Object): zlib inflate options.
|
* - options (Object): zlib inflate options.
|
||||||
*
|
*
|
||||||
|
@ -410,4 +410,4 @@ function ungzip(input, options) {
|
||||||
* by header.content. Done for convenience.
|
* by header.content. Done for convenience.
|
||||||
**/
|
**/
|
||||||
|
|
||||||
export { ungzip }
|
export { gunzip }
|
|
@ -1,2 +1,2 @@
|
||||||
export { gzip } from './gzip.js'
|
export { gzip } from './gzip.js'
|
||||||
export { ungzip } from './ungzip.js'
|
export { gunzip } from './gunzip.js'
|
||||||
|
|
Loading…
Reference in New Issue