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

Commit 07104aa

Browse files
committed
es5
1 parent fb24537 commit 07104aa

File tree

4 files changed

+35
-31
lines changed

4 files changed

+35
-31
lines changed

.travis.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
sudo: false
22
language: node_js
33
node_js:
4+
- "4.2.0"
5+
- "6.9.0"
46
- "7.4.0"

example.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1-
const request = require('superagent')
2-
const through = require('through2')
3-
const stream = require('./')
1+
var request = require('superagent')
2+
var through = require('through2')
3+
var stream = require('./')
44

5-
const req = request.get('http://localhost:8000/file.xlsx')
5+
var req = request.get('http://localhost:8000/file.xlsx')
66
.buffer(false)
77
.pipe(stream())
8-
.on('data', (d) => console.log(String(d), 'line'))
8+
.on('data', function (d) {
9+
console.log(String(d), 'line')
10+
}
911
.on('end', console.log)

index.js

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
1-
const Excel = require('exceljs')
2-
const through = require('through2')
3-
const duplex = require('duplexify')
1+
var Excel = require('exceljs')
2+
var through = require('through2')
3+
var duplex = require('duplexify')
44

5-
module.exports = () => {
6-
const input = through()
7-
const second = through()
8-
const workbook = new Excel.Workbook()
5+
module.exports = function exceljsStream() {
6+
var input = through()
7+
var second = through()
8+
var workbook = new Excel.Workbook()
99

10-
let headers = null
11-
const reader = workbook.xlsx.read(input)
12-
.then((worksheet) => {
13-
workbook.eachSheet((sheet, id) => {
14-
sheet.eachRow((row, id) => {
10+
var headers = null
11+
var reader = workbook.xlsx.read(input)
12+
.then(function (worksheet) {
13+
workbook.eachSheet(function (sheet, id) {
14+
sheet.eachRow(function (row, id) {
1515
if (id === 1 || !headers) {
1616
headers = row.values
1717
return
1818
}
19-
let item = {}
20-
row.values.forEach((v, k) => {
19+
var item = {}
20+
row.values.forEach(function (v, k) {
2121
if (!headers) return
2222
item[headers[k]] = v
2323
})

test/index.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
1-
const fs = require('fs')
2-
const should = require('should')
3-
const stream = require('stream')
4-
const exs = require('..')
1+
var fs = require('fs')
2+
var should = require('should')
3+
var stream = require('stream')
4+
var exs = require('..')
55

6-
describe('exceljs-through-stream', () => {
7-
it('should export a function', (done) => {
6+
describe('exceljs-through-stream', function () {
7+
it('should export a function', function (done) {
88
should(typeof exs).equal('function')
99
done()
1010
})
11-
it('should export a function that returns a stream', (done) => {
11+
it('should export a function that returns a stream', function (done) {
1212
should(exs() instanceof stream)
1313
done()
1414
})
15-
it('parse xlsx files', (done) => {
16-
const file = fs.createReadStream(__dirname + '/file.xlsx')
17-
const res = []
15+
it('parse xlsx files', function (done) {
16+
var file = fs.createReadStream(__dirname + '/file.xlsx')
17+
var res = []
1818
file.pipe(exs())
19-
.on('data', (d) => {
19+
.on('data', function (d) {
2020
res.push(JSON.parse(String(d)))
2121
})
22-
.on('end', () => {
22+
.on('end', function () {
2323
should(res.length).equal(4)
2424
should(JSON.stringify(res[0])).equal(
2525
JSON.stringify({

0 commit comments

Comments
 (0)