Socket
Socket
Sign inDemoInstall

libqp

Package Overview
Dependencies
0
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    libqp

Encode and decode quoted-printable strings according to rfc2045


Version published
Weekly downloads
936K
decreased by-17.34%
Maintainers
1
Install size
16.5 kB
Created
Weekly downloads
 

Changelog

Source

2.1.0 (2024-02-23)

Features

  • deploy: Added autodeploy system (def1b22)

Readme

Source

libqp

Encode and decode quoted-printable strings according to RFC2045.

Usage

Install with npm

npm install libqp

Require in your script

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

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

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.

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.

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

Keywords

FAQs

Last updated on 23 Feb 2024

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc