npm.io
2.0.0 • Published 9 months ago

foldline

Licence
MIT
Version
2.0.0
Deps
0
Size
7 kB
Vulns
0
Weekly
0

foldline

npm version npm license npm downloads

Folds a long line according to the RFC 5322

Note: There are other documents, specifically the MIME documents (RFC 2045, RFC 2046, RFC 2049, RFC 4288, RFC 4289), that extend (and limit) this specification to allow for different sorts of message bodies.

Install via npm

$ npm install --save foldline

Usage

var foldLine = require( 'foldline' )

Example

foldLine( 'Subject: from x.y.test by example.net via TCP with ESMTP id ABC12345 for <mary@example.net>', 30 )
'Subject: from x.y.test by \r\n' +
  ' example.net via TCP with \r\n' +
  ' ESMTP id ABC12345 for \r\n' +
  ' <mary@example.net>'

API

Constants
  • number foldLine.DEFAULT_LINE_LENGTH = 78
  • number foldLine.MIN_LINE_LENGTH = 1
  • number foldLine.MAX_LINE_LENGTH = 998
Methods
foldLine( value[, maxLength[, minLength]] )
  • string value: String to be folded
  • number maxLength: Maximum line length (excluding <CRLF>).
    Hard line length limit. Any line longer than this will be hard-folded.
    Defaults to foldLine.DEFAULT_LINE_LENGTH (78).
  • number minLength: Minimum line length (excluding <CRLF>).
    Lines that would be shorter than this limit when soft-folded will be hard-folded instead, in order to maintain more consistent line lengths.
    Defaults to maxLength / 3.

Returns string

foldLine.unfold( value )
  • string value: String to be unfolded

Returns string

Tests

$ npm test

Keywords