Comparing version 4.4.1 to 4.5.0
{ | ||
"name": "keyv", | ||
"version": "4.4.1", | ||
"version": "4.5.0", | ||
"description": "Simple key-value storage with support for multiple backends", | ||
@@ -35,3 +35,2 @@ "main": "src/index.js", | ||
"dependencies": { | ||
"compress-brotli": "^1.3.8", | ||
"json-buffer": "3.0.1" | ||
@@ -41,4 +40,4 @@ }, | ||
"@keyv/test-suite": "*", | ||
"ava": "^4.3.1", | ||
"eslint": "^8.22.0", | ||
"ava": "^4.3.0", | ||
"eslint": "^8.19.0", | ||
"eslint-plugin-promise": "^6.0.0", | ||
@@ -45,0 +44,0 @@ "nyc": "^15.1.0", |
@@ -190,2 +190,16 @@ <h1 align="center"> | ||
## Compression | ||
Keyv supports `gzip` and `brotli` compression. To enable compression, pass the `compress` option to the constructor. | ||
```js | ||
const KeyvGzip = require('@keyv/compress-gzip'); | ||
const Keyv = require('keyv'); | ||
const keyvGzip = new KeyvGzip();; | ||
const keyv = new Keyv({ compression: KeyvGzip }); | ||
``` | ||
You can also pass a custom compression function to the `compression` option. Following the pattern of the official compression adapters. | ||
## API | ||
@@ -228,2 +242,9 @@ | ||
#### options.compression | ||
Type: `@keyv/compress-<compression_package_name>`<br> | ||
Default: `undefined` | ||
Compression package to use. See [Compression](#compression) for more details. | ||
#### options.serialize | ||
@@ -320,3 +341,2 @@ | ||
1) [Yarn V1](https://yarnpkg.com/getting-started/install) | ||
2) [Lerna](https://lerna.js.org/) | ||
3) [Docker](https://docs.docker.com/get-docker/) | ||
@@ -343,3 +363,3 @@ | ||
Once the project is running, you can execute a variety of commands. The root workspace and each subpackage contain a `package.json` file with a `scripts` field listing all the commands that can be executed from that directory. This project also supports native `yarn`, `lerna`, and `docker` commands. | ||
Once the project is running, you can execute a variety of commands. The root workspace and each subpackage contain a `package.json` file with a `scripts` field listing all the commands that can be executed from that directory. This project also supports native `yarn`, and `docker` commands. | ||
@@ -346,0 +366,0 @@ Here, we'll cover the primary commands that can be executed from the root directory. Unless otherwise noted, these commands can also be executed from a subpackage. If executed from a subpackage, they will only affect that subpackage, rather than the entire workspace. |
@@ -5,3 +5,2 @@ 'use strict'; | ||
const JSONB = require('json-buffer'); | ||
const compressBrotli = require('compress-brotli'); | ||
@@ -55,9 +54,7 @@ const loadStore = options => { | ||
if (this.opts.compress) { | ||
const brotli = compressBrotli(this.opts.compress.opts); | ||
this.opts.serialize = async ({value, expires}) => brotli.serialize({value: await brotli.compress(value), expires}); | ||
this.opts.deserialize = async data => { | ||
const {value, expires} = brotli.deserialize(data); | ||
return {value: await brotli.decompress(value), expires}; | ||
}; | ||
if (this.opts.compression) { | ||
const compression = this.opts.compression; | ||
const {serialize, deserialize} = compression.opts; | ||
this.opts.serialize = serialize; | ||
this.opts.deserialize = deserialize; | ||
} | ||
@@ -64,0 +61,0 @@ |
26391
1
406
318
- Removedcompress-brotli@^1.3.8
- Removed@types/json-buffer@3.0.2(transitive)
- Removedcompress-brotli@1.3.12(transitive)