Skip to content
This repository was archived by the owner on Aug 5, 2022. It is now read-only.

Commit 00c59b4

Browse files
committed
duplex
1 parent 1230b9b commit 00c59b4

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

example.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ const through = require('through2')
33
const stream = require('./')
44

55
const req = request.get('http://localhost:8000/file.xlsx')
6-
stream(req).on('data', (d) => console.log(String(d)))
6+
.pipe(stream())
7+
.on('data', (d) => console.log(String(d)))

index.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
const Excel = require('exceljs')
22
const through = require('through2')
3+
const duplex = require('duplexify')
34
const Stream = require('stream')
45
const readable = new Stream.Readable()
56

6-
module.exports = (input) => {
7+
module.exports = () => {
8+
const input = through()
79
const workbook = new Excel.Workbook()
810
readable._read = () => {
911
let headers = null
@@ -25,5 +27,5 @@ module.exports = (input) => {
2527
readable.push(null)
2628
})
2729
}
28-
return readable
30+
return duplex(input, readable)
2931
}

0 commit comments

Comments
 (0)