# libqp

> Encode and decode quoted-printable strings according to rfc2045

Latest version **2.1.1** (published 2024-11-29) · MIT license · 0 weekly downloads

## Install

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

## Health

**Score 38/100 (D)** — status: maintenance-mode.

Positive: has types package; no vulnerabilities; has provenance; high quality score.

Warnings: low downloads; no esm support.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.1.1 |
| Published | 2024-11-29 |
| First published | 2014-06-18 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | separate (@types/libqp) |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 21.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 7 |
| Author | Andris Reinman |
| Maintainers | andris |
| Keywords | quoted-printable, mime |

## Links

- npm: https://www.npmjs.com/package/libqp
- Repository: https://github.com/nodemailer/libqp
- Issues: https://github.com/nodemailer/libqp/issues
- npm.io page: https://npm.io/package/libqp

## Alternatives

- [@lexical/table](https://npm.io/package/@lexical/table.md) — 3.0M weekly downloads
- [mantine-datatable](https://npm.io/package/mantine-datatable.md) — 98.2K weekly downloads
- [react-native-collapsible-tab-view](https://npm.io/package/react-native-collapsible-tab-view.md) — 70.6K weekly downloads
- [@handsontable/vue3](https://npm.io/package/@handsontable/vue3.md) — 16.1K weekly downloads
- [vuewordcloud](https://npm.io/package/vuewordcloud.md) — 7.2K weekly downloads

## Recent versions

- 2.1.1 (latest) — 2024-11-29
- 2.1.0 — 2024-02-23
- 2.0.1 — 2022-11-03
- 2.0.0 — 2022-11-03
- 1.1.0 — 2015-09-24
- 1.0.0 — 2015-04-03
- 0.1.1 — 2014-06-18
- 0.1.0 — 2014-06-18

## README

# libqp

Encode and decode quoted-printable strings according to [RFC2045](http://tools.ietf.org/html/rfc2045#section-6.7).

## Usage

Install with npm

```
npm install libqp
```

Require in your script

```javascript
const libqp = require('libqp');
```

### Encode values

Encode Buffer objects or unicode strings with

```
libqp.encode(val) → String
```

Where

-   **val** is a Buffer or an unicode string

**Example**

```javascript
libqp.encode('jõgeva');
// j=C3=B5geva
```

### Wrap encoded values

Quoted-Printable encoded lines are limited to 76 characters but `encode` method might return lines longer than the limit.

To enforce soft line breaks on lines longer than 76 (or any other length) characters, use `wrap`

```
libqp.wrap(str[, lineLength]) → String
```

Where

-   **str** is a Quoted-Printable encoded string
-   **lineLength** (defaults to 76) is the maximum allowed line length. Any longer line will be soft wrapped

**Example**

```javascript
libqp.wrap('abc j=C3=B5geva', 10);
// abc j=\r\n
// =C3=B5geva
```

### Transform Streams

`libqp` makes it possible to encode and decode streams with `libqp.Encoder` and `libqp.Decoder` constructors.

### Encoder Stream

Create new Encoder Stream with

```
const encoder = new libqp.Encoder([options])
```

Where

-   **options** is the optional stream options object with an additional option `lineLength` if you want to use any other line length than the default 76 characters (or set to `false` to turn the soft wrapping off completely)

**Example**

The following example script reads in a file, encodes it to Quoted-Printable and saves the output to a file.

```javascript
var libqp = require('libqp');
var fs = require('fs');
var source = fs.createReadStream('source.txt');
var encoded = fs.createReadStream('encoded.txt');
var encoder = new libqp.Encoder();

source.pipe(encoder).pipe(encoded);
```

### Decoder Stream

Create new Decoder Stream with

```
const decoder = new libqp.Decoder([options])
```

Where

-   **options** is the optional stream options object

**Example**

The following example script reads in a file in Quoted-Printable encoding, decodes it and saves the output to a file.

```javascript
const libqp = require('libqp');
const fs = require('fs');
let encoded = fs.createReadStream('encoded.txt');
let dest = fs.createReadStream('dest.txt');
let decoder = new libqp.Decoder();

encoded.pipe(decoder).pipe(dest);
```

## License

**MIT**

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