# jsonfile-compressed-brotli

> similar to jsonfile-compressed, but uses brotli compression instead of LZMA (7-zip)

Latest version **0.0.117** (published 2022-04-25) · MIT license · 0 weekly downloads

## Install

```sh
npm install jsonfile-compressed-brotli
pnpm add jsonfile-compressed-brotli
yarn add jsonfile-compressed-brotli
bun add jsonfile-compressed-brotli
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.117 |
| Published | 2022-04-25 |
| First published | 2022-04-16 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 5.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | stonkpunk |
| Maintainers | stonkpunk |
| Keywords | compression, compress, jsonpack, jsonfile, json, shrink, brotli |

## Links

- npm: https://www.npmjs.com/package/jsonfile-compressed-brotli
- Homepage: https://github.com/stonkpunk/my-npm-modules/tree/main/jsonfile-compressed-brotli
- npm.io page: https://npm.io/package/jsonfile-compressed-brotli

## Dependencies (1)

- [json-shrink](https://npm.io/package/json-shrink.md) 0.0.124

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 0.0.117 (latest) — 2022-04-25
- 0.0.116 — 2022-04-16
- 0.0.115 — 2022-04-16
- 0.0.114 — 2022-04-16
- 0.0.113 — 2022-04-16
- 0.0.112 — 2022-04-16

## README

# jsonfile-compressed-brotli

similar to [jsonfile](https://www.npmjs.com/package/jsonfile), but with automatic jsonpack + brotli compression+decompression

different version of [jsonfile-compressed](https://www.npmjs.com/package/jsonfile-compressed) that uses brotli compression instead of LZMA (7-zip)

```javascript
readFile(fileName, jsonPackEnabled = false, callback) 
writeFile(fileName, obj, jsonPackEnabled = false, callback)
readFileSync(fileName, jsonPackEnabled? = false)
writeFileSync(fileName, obj, jsonPackEnabled? = false)
```

Note that this lib has `jsonPackEnabled` false by default, unlike `jsonfile-compressed`

## Installation

```sh
npm i jsonfile-compressed-brotli
```

## Usage

```javascript
var jfc = require('jsonfile-compressed-brotli');
var obj = {"ok":"here is some stuff"};

jfc.writeFileSync("test.json", obj); //note - file extension is ignored
//object is saved as test.jsonpack.br

var obj_decompressed = jfc.readFileSync("test.json"); //file extension optional
//^^^filename is automatically changed internally, from test.json to to test.jsonpack.br

console.log(obj_decompressed);
//result:
//{ ok: 'here is some stuff' }
```

## Usage - jsonpack disabled

sometimes the jsonpacked versions can be larger than the unpacked versions once compression is applied. make sure to check the compressed filesizes for your data to see if jsonpack is helping or not.

```javascript
var obj = {"ok":"here is some stuff"};
var jsonPackEnabled = false;

jfc.writeFileSync("test2.json", obj, jsonPackEnabled);
//saved as test2.json.br 

var obj_decompressed = jfc.readFileSync("test2.json", jsonPackEnabled);
console.log(obj_decompressed);
//result:
//{ ok: 'here is some stuff' }
```

## Usage - async

```javascript
var obj = {"ok2":"here is some stuff2"};
var jsonPackEnabled=true;

jfc.writeFile("test3.json", obj, jsonPackEnabled,function(err,res){
    jfc.readFile("test3.json", jsonPackEnabled, function(err2,res2){
        console.log("async",res2);
        //result
        //async { ok2: 'here is some stuff2' }
    });
});
```

## See Also
- [jsonfile-compressed](https://www.npmjs.com/package/jsonfile-compressed)
- [json-shrink](https://www.npmjs.com/package/json-shrink) 
- [jsonfile](https://www.npmjs.com/package/jsonfile)


[![stonks](https://i.imgur.com/UpDxbfe.png)](https://www.npmjs.com/~stonkpunk)

---
_Source: https://npm.io/package/jsonfile-compressed-brotli · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
