PlaintextStream

PlaintextStream

A Readable stream implementation that exposes convenience methods for writing to various locations like files and strings.
 // Run a decrypt, which returns a PlaintextStream.
 plaintextStream = await client.decrypt(decryptParams);

 // Write the plaintext to a local file.
 await stream.toFile("/tmp/plain.txt");
   

Methods

(async) toBuffer() → {Buffer}

Dump the stream content to a buffer. This will consume the stream.
Returns:
- the plaintext in Buffer form.
Type
Buffer

(async) toFile(filepath, encoding)

Dump the stream content to a local file. This will consume the stream.
Parameters:
Name Type Description
filepath string the path of the local file to write plaintext to.
encoding string the charset encoding to use. Defaults to utf-8.

(async) toString(encoding) → {string}

Dump the stream content to a string. This will consume the stream.
Parameters:
Name Type Description
encoding string the charset encoding to use. Defaults to utf-8.
Returns:
- the plaintext in string form.
Type
string