Backend half

This commit is contained in:
2025-07-11 19:56:28 +02:00
parent fa868e7c1d
commit 8600fa7c1d
19426 changed files with 3750448 additions and 8108 deletions
+19
View File
@@ -0,0 +1,19 @@
MIT License
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
+76
View File
@@ -0,0 +1,76 @@
# node-gzip
> Gzip and ungzip in Node.js
Tiny and easy to use wrapper around [zlib.gzip](https://nodejs.org/api/zlib.html#zlib_zlib_gzip_buffer_options_callback) and [zlib.gunzip](https://nodejs.org/api/zlib.html#zlib_zlib_gunzip_buffer_options_callback) to support promises.
```js
const compressed = await gzip('Hello World');
```
## Install
```sh
npm install node-gzip --save
```
## Examples
#### With Promises
```js
const {gzip, ungzip} = require('node-gzip');
gzip('Hello World')
.then((compressed) => {
return ungzip(compressed);
})
.then((decompressed) => {
console.log(decompressed.toString()); //Hello World
});
```
#### With async / await
```js
const {gzip, ungzip} = require('node-gzip');
const compressed = await gzip('Hello World');
const decompressed = await ungzip(compressed);
console.log(decompressed.toString()); //Hello World
```
## Options
Pass options just like with [Zlib](https://nodejs.org/api/zlib.html). See all [options](https://nodejs.org/api/zlib.html#zlib_class_options).
```js
await gzip('Hello World', {...});
```
## Description
#### gzip(input[,options])
* input: `Buffer | TypedArray | DataView | ArrayBuffer | string`
* returns: `Buffer`
#### ungzip(input[,options])
* input: `Buffer | TypedArray | DataView | ArrayBuffer | string`
* returns: `Buffer`
Use `toString()` after `ungzip` to convert the Buffer into a string.
Supports Node.js version 0.12 and higher.
---
### License
node-gzip is [MIT licensed](./LICENSE).
+22
View File
@@ -0,0 +1,22 @@
'use strict';
var zlib = require('zlib');
module.exports = {
gzip: function gzip(input, options) {
var promise = new Promise(function (resolve, reject) {
zlib.gzip(input, options, function (error, result) {
if (!error) resolve(result);else reject(Error(error));
});
});
return promise;
},
ungzip: function ungzip(input, options) {
var promise = new Promise(function (resolve, reject) {
zlib.gunzip(input, options, function (error, result) {
if (!error) resolve(result);else reject(Error(error));
});
});
return promise;
}
};
+34
View File
@@ -0,0 +1,34 @@
{
"name": "node-gzip",
"version": "1.1.2",
"description": "Simply gzip and ungzip in Node.js with promises",
"main": "dist/index.js",
"scripts": {
"build": "rm -rf dist && mkdir dist && babel src --out-dir dist"
},
"author": "Rebsos",
"repository": {
"type": "git",
"url": "https://github.com/Rebsos/node-gzip.git"
},
"keywords": [
"node",
"gzip",
"compress",
"promise",
"gunzip",
"ungzip",
"decompress",
"uncompress",
"gz",
"zlib",
"async",
"await",
"promises"
],
"license": "MIT",
"devDependencies": {
"babel-cli": "^6.26.0",
"babel-preset-env": "^1.6.1"
}
}