UUE decoder and encoder for Node.js
npm install uueThe UUE module is able to perform uuencoding of a file (or Node.js Buffer) to a text message. This module is also able to find uuencoded files in text messages and decode them.
The module is named after a common .UUE suffix for Fidonet echomail areas where uuencoded files are posted (sometimes the results of such encoding are also known as “UUE codes”).
The module is written in JavaScript and requires Node.js to run.
* Starting from v3.0.0, this module requires Node.js version 4.0.0 or newer.
* You may run older versions of this module in Node.js version 0.10.x or 0.12.x. These older versions of this module, however, had to contain an additional dependency (array.prototype.findindex) as a polyfill for a missing ECMAScript 2015 (ES6) feature which is now a part of Node.js. Those older versions of Node.js are themselves not maintained by their developers after 2016-12-31.
npm install uue
npm install https://github.com/Mithgol/node-uue/tarball/master
README because the package's version is not planned to grow after changes when they happen in README only. (And npm publish --force is forbidden nowadays.)
require() the installed module, you get an object that has the following methods:
encodeSource is a string, it is interpreted as a path of some file, and that file is uuencoded.
encodeSource is a Node.js Buffer, the contents of that buffer become uuencoded.
.encode method, a synchronous reading of the given file is performed. If you need an asynchronous reading, perform it yourself and give the resulting Buffer to the .encode method.
encodeOptions parameter is an object with the following optional properties:
mode — read/write/execute permissions for the file.
mode property may be given as a string (of octal digits) or as a number (for example, '666' and 438 are equivalent). You may even use an octal number if your engine supports this ECMAScript 6 feature. (For example, '644' and 0o644 are equivalent in Node 4.0.0 or newer.)
mode property of the given file's fs.Stats object are used (or '644' if a Buffer is given in encodeSource instead of a file).
filename — a file's name to be given in UUE codes. (For example, if encodeOptions is {mode:'664', filename:'filename.ext'}, then the first line of UUE codes is begin 664 filename.ext.) If this property is omitted, then path.basename(encodeSource) is used (or 'buffer.bin' if a Buffer is given in encodeSource instead of a file).
eol — end-of-line character(s). If this property is omitted, \n (\x0A) is used (as in Web or UNX applications). You may want to set encodeOptions.eol equal to os.EOL on other systems. The value of encodeOptions.eol is used only as a separator between lines of UUE codes, but neither in the beginning nor at the end of the returned string.
'Cat', as in Wikipedia):
filename, finds the uuencoded file in the given text, decodes the file and returns it as a Node.js Buffer.
text are expected to be separated by '\n' (\x0A).
filename) are ignored. (In other words, even if text contains several uuencoded files, it is not necessary for the file with the given filename to be the first of them: files with other names may precede it, and it still will be found and decoded nevertheless.)
filename (case-sensitive), only the first is returned (its other namesakes are ignored).
text, null is returned.
text, decodes them and returns as an array.
name — the file's name (as it appeared in UUE codes);
data — a Node.js Buffer containing the file's decoded contents.
text are expected to be separated by '\n' (\x0A).
text. If several uuencoded files have the same name (case-sensitive), only the first file is returned (its other namesakes are ignored).
text does not seem to contain any uuencoded files, an empty array ([]) is returned.
text and splits that text into an array of text blocks and UUE blocks.
name — the file's name (as it appeared in UUE codes);
data — a Node.js Buffer containing the file's decoded contents.
source — a JavaScript string containing source UUE codes of the file from (and including) the beginning 'begin' to (and including) the final 'end'.
type — always the JavaScript string 'UUE'. Might help in further processing of the array (i.e. if other types of blocks are going to be decoded from text blocks; for example, in an abstract syntax tree).
text are expected to be separated by '\n' (\x0A).
text. Unlike .decodeAllFiles, even if several uuencoded files have the same name, none of them becomes deliberately ignored.
'') do not become text blocks of the returned array. (For example, if the given text starts with UUE codes, then the first of the returned blocks is a UUE block instead of an empty text block.) This nuance makes this method slightly different from its String's namesake (where 'foo'.split(/(f)/) returns ['', 'f', 'oo']) and thus typeof has to be used instead of checking whether some element's index is even (or odd).
'\n' (\x0A) that immediately precedes or follows a UUE block does not become a part of that block; instead of it such separator becomes a part of an adjacent JavaScript string.
end.
npm install mocha -g) or locally (npm install mocha in the directory of the UUE module).
npm install jshint -g) or locally (npm install jshint in the directory of the UUE module).
npm test (in the directory of the UUE module).
LICENSE file).