# lzo

> node.js bindings for lzo compression

Latest version **0.4.11** (published 2019-05-07) · MIT license · 0 weekly downloads

## Install

```sh
npm install lzo
pnpm add lzo
yarn add lzo
bun add lzo
```

## 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.4.11 |
| Published | 2019-05-07 |
| First published | 2016-05-06 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 519 KB |
| Known vulnerabilities | 0 |
| Install scripts | yes |
| GitHub stars | 10 |
| Author | schroffl |
| Maintainers | schroffl |

## Links

- npm: https://www.npmjs.com/package/lzo
- Repository: https://github.com/schroffl/node-lzo
- Homepage: https://github.com/schroffl/node-lzo#readme
- Issues: https://github.com/schroffl/node-lzo/issues
- npm.io page: https://npm.io/package/lzo

## Dependencies (1)

- [bindings](https://npm.io/package/bindings.md) ~1.2.1

## Recent versions

- 0.4.11 (latest) — 2019-05-07
- 0.4.10 — 2018-12-04
- 0.4.9 — 2018-10-24
- 0.4.8 — 2018-10-24
- 0.4.7 — 2018-10-12
- 0.4.6 — 2018-10-12
- 0.4.5 — 2018-10-12
- 0.4.3 — 2018-01-24
- 0.4.1 — 2017-10-07
- 0.4.0 — 2017-01-03
- 0.3.1 — 2016-10-09
- 0.3.0 — 2016-05-08
- 0.2.0 — 2016-05-06
- 0.1.1 — 2016-05-06
- 0.1.0 — 2016-05-06

## README

# node-lzo [![npm version](https://badge.fury.io/js/lzo.svg)](https://badge.fury.io/js/lzo)
Node.js Bindings for [LZO Compression](http://www.oberhumer.com/opensource/lzo/)

## Example
```javascript
const lzo = require('lzo');

console.log('Current version:', lzo.version, '-', lzo.versionDate);

let str = 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam',
    compressed = lzo.compress(str);

console.log('Original Length:', str.length, '-- Compressed length:', compressed.length);

let decompressed = lzo.decompress(compressed);

console.log('Decompressed Length:', decompressed.length);
console.log(decompressed.toString());
```

## Properties
#### version
The version of [LZO](http://www.oberhumer.com/opensource/lzo/) being used.

#### versionDate
The date on which the version was released.

#### errors
An object containing the lzo error codes as seen below.


## Methods
#### compress(data, *length*)
If *data* is not a Buffer, the function will try to convert it via `Buffer.from`.
If you specify a *length*, the function will allocate that much memory for the compressed data.  
Returns the compressed data as a Buffer.

#### decompress(data, *length*)
If *data* is not a Buffer, the function will try to convert it via `Buffer.from`.
If you specify a *length*, the function will allocate that much memory for the decompressed data. I suggest you to do so whenever you know the length.  
Returns the decompressed data as a Buffer.

## Errors
Code | Description
-------------: | :------------- 
`-1` | LZO\_E\_ERROR
`-2` | LZO\_E\_OUT\_OF\_MEMORY
`-3` | LZO\_E\_NOT\_COMPRESSIBLE
`-4` | LZO\_E\_INPUT\_OVERRUN
`-5` | LZO\_E\_OUTPUT\_OVERRUN
`-6` | LZO\_E\_LOOKBEHIND_OVERRUN
`-7` | LZO\_E\_EOF\_NOT\_FOUND
`-8` | LZO\_E\_INPUT\_NOT\_CONSUMED
`-9` | LZO\_E\_NOT\_YET\_IMPLEMENTED
`-10` | LZO\_E\_INVALID\_ARGUMENT
`-11` | LZO\_E\_INVALID\_ALIGNMENT
`-12` | LZO\_E\_OUTPUT\_NOT\_CONSUMED
`-99` | LZO\_E\_INTERNAL\_ERROR

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