Compare commits

...

1 Commits

Author SHA1 Message Date
yutent 07aff737e0 ungzip更名为gunzip 2023-05-29 17:10:11 +08:00
4 changed files with 14 additions and 14 deletions

View File

@ -19,18 +19,18 @@ npm install @bytedo/gzip
```js
import { gzip , ungzip } from '@bytedo/gzip' // use importmap
import { gzip , gunzip } from '@bytedo/gzip' // use importmap
// 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 { 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 txt = ungzip(base64Str) // return hello world
let txt = gunzip(base64Str) // return hello world
```

View File

@ -2,10 +2,10 @@
"name": "@bytedo/gzip",
"type": "module",
"description": "浏览器端的gzip库, fork于pako, 仅调整语法为esm, 并只保留gzip的导出。",
"version": "2.1.0",
"version": "2.1.1",
"keywords": [
"gzip",
"ungzip"
"gunzip"
],
"files": [
"dist/*"
@ -16,9 +16,9 @@
},
"scripts": {
"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": "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": {
"esbuild": "^0.17.16"

View File

@ -356,9 +356,9 @@ Inflate.prototype.onEnd = function (status) {
* - data (Uint8Array|ArrayBuffer): input data to decompress.
* - 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
* separate `ungzip` method.
* separate `gunzip` method.
*
* 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)
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.
* - options (Object): zlib inflate options.
*
@ -410,4 +410,4 @@ function ungzip(input, options) {
* by header.content. Done for convenience.
**/
export { ungzip }
export { gunzip }

View File

@ -1,2 +1,2 @@
export { gzip } from './gzip.js'
export { ungzip } from './ungzip.js'
export { gunzip } from './gunzip.js'