Created
April 3, 2019 12:01
-
-
Save jamesknelson/3c4661b826a88bf897db5353b25fbae2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const CombinedStream = require('combined-stream2'); | |
function concatStringsAndStreams(strings, ...args) { | |
let combinedStream = CombinedStream.create() | |
combinedStream.append(Buffer.from(strings[0], 'utf8')) | |
for (let i = 0; i < args.length; i++) { | |
let arg = args[i] | |
let string = strings[i+1] | |
if (arg && arg.pipe) { | |
combinedStream.append(arg) | |
} | |
else { | |
combinedStream.append(Buffer.from(String(arg), 'utf8')) | |
} | |
combinedStream.append(Buffer.from(String(string), 'utf8')) | |
} | |
return combinedStream | |
} | |
module.exports = concatStringsAndStreams |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment