2.0.3 • Published 4 years ago
preface v2.0.3
Preface
Prepend data to a stream or file.
API
const preface = require('preface')
const PrependStream = require('preface').PrependStreamclass PrependStream extends Transform
A transform stream that prepends data to the incoming stream.
new PrependStream(data, options)
Creates a new instance of PrependStream.
data: String|Buffer|null: The data to prepend to the input stream. Can accept any object in object mode.options: Object: Options to pass to the Transform constructor.options.enc: String: Encoding of the data to push.
preface(inputStream, data, [options])
Returns a new instance of PrependStream constructed with the specified arguments. This is in a way just a function version to set up the PrependStream class.
inputStream: stream.Readable(or any Readable-compatible API)data: String|Buffer|nullorany: Data to prepend to the stream. Can accept any object in object mode.options: Object: options to pass to the PrependStream constructor.
CLI
Install as a global module to do some awesome:
- First unnamed argument: Data to prepend to the stream.
-i/--in: Path to input file. Uses standard input if not provided.-o/--out: Path to output file. Uses standard output if not provided.
Examples:
echo 1234 | preface abcd(Try this one!)preface abcd < in.txt > out.txtpreface abcd --in in.txt --out out.txt
License
MIT