foldline
v2.0.0
Published
Folds a long line according to the RFC 5322
Maintainers
Readme
foldline
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 foldlineUsage
var foldLine = require( 'foldline' )Example
foldLine( 'Subject: from x.y.test by example.net via TCP with ESMTP id ABC12345 for <[email protected]>', 30 )'Subject: from x.y.test by \r\n' +
' example.net via TCP with \r\n' +
' ESMTP id ABC12345 for \r\n' +
' <[email protected]>'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 tofoldLine.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 tomaxLength / 3.
Returns string
foldLine.unfold( value )
- string
value: String to be unfolded
Returns string
Tests
$ npm test