Skip to content

Commit

Permalink
refactor: Pull write-to-stream out into its own file
Browse files Browse the repository at this point in the history
  • Loading branch information
jezhiggins committed Apr 27, 2020
1 parent 732c874 commit 12f1172
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
14 changes: 1 addition & 13 deletions lib/File-builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const fs = require('fs')
const csvStringify = require('csv-string').stringify
const Transformer = require('./Transformer')
const upath = require('upath')
const _ = require('lodash')
const writeToStream = require('./write-to-stream')

class FileBuilder {
constructor (options) {
Expand Down Expand Up @@ -175,16 +175,4 @@ function findMatchingKey (keys, value) {
}
} // findMatchingKey

async function writeToStream(stream, output) {
return new Promise((resolve, reject) => {
stream.write(
output,
err => {
if (err) return reject(err)
resolve()
}
)
})
} // writeToStream

module.exports = FileBuilder
13 changes: 13 additions & 0 deletions lib/write-to-stream.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
async function writeToStream(stream, output) {
return new Promise((resolve, reject) => {
stream.write(
output,
err => {
if (err) return reject(err)
resolve()
}
)
})
} // writeToStream

module.exports = writeToStream

0 comments on commit 12f1172

Please sign in to comment.