-
Notifications
You must be signed in to change notification settings - Fork 7
Conversation
* @param {object} writeStream Handle to a {@link https://nodejs.org/api/stream.html#stream_class_stream_writable_1|stream.Writable} instance to output to | ||
* @see {@link CSVProcessor|CSVProcessor} for more info | ||
*/ | ||
HMDAEngine.prototype.exportAll = function(year, errorType, writeStream) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know we called it "export all" in our discussions, but since this function is limited to the errorType, should we change the name to exportType
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
So my main concern with this is that it the CSVProcessor requires a write stream to be passed into it. I've already looked and found that there are ways to create streams in the browser, but since the file needs to be complete before we can even download it, would it make more sense to just have the engine return a string? |
@poorgeek I had it use a write stream because that's the easiest way to work with the csv module as it's all modeled after the node stream api. Since every component in the chain is a stream they implicitly handle the details of passing data between them so we don't have to. It also means that once the end points close the stream every component in the chain is flushed and closed as well so we don't have to worry about any open handles or memory leaks. |
@stevejameskent After thinking through this a bit, I think the API should consist of 4 functions..
Shouldn't need year param, as you can use In the case of 1 and 2, you can take that stream and pipe it elsewhere (like on a server, to an http stream for a response) and in the case of 3 and 4, you can |
👍 |
This resolves cfpb/hmda-pilot#313 and cfpb/hmda-pilot#314