Skip to content

Commit a0fca5d

Browse files
authored
refactor!: drop through2 (#178)
Ref https://github.com/rvagg/through2#do-you-need-this Closes #177 BREAKING CHANGES: Require node 10 and higher.
1 parent a72f822 commit a0fca5d

5 files changed

Lines changed: 26 additions & 24 deletions

File tree

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
language: node_js
22
node_js:
3+
- 14
34
- 12
45
- 10
5-
- 8
66
script:
77
- 'npm run lint'
88
- 'npm run test'

bin/csv-parser

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
const { EOL } = require('os')
44
const minimist = require('minimist')
5-
const through = require('through2')
5+
const { Transform } = require('stream');
66
const fs = require('fs')
77
const csv = require('../')
88
const pkg = require('../package.json')
@@ -80,9 +80,12 @@ if (filename === '-' || !filename) {
8080
}
8181

8282
const serialize = () => {
83-
return through.obj((obj, enc, cb) => {
84-
cb(null, JSON.stringify(obj) + EOL)
85-
})
83+
return new Transform({
84+
objectMode: true,
85+
transform(obj, enc, cb) {
86+
cb(null, JSON.stringify(obj) + EOL)
87+
}
88+
});
8689
}
8790

8891
input

examples/transform.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const write = require('csv-write-stream')
2-
const through = require('through2')
2+
const { Transform } = require('stream')
33
const parse = require('../')
44
const path = require('path')
55
const fs = require('fs')
@@ -10,7 +10,7 @@ const fs = require('fs')
1010
// .pipe(fs.createWriteStream('./file'))
1111
fs.createReadStream(path.join(__dirname, '../test/data/dummy.csv'))
1212
.pipe(parse())
13-
.pipe(through.obj(transform))
13+
.pipe(new Transform({ objectMode: true, transform }))
1414
.pipe(write())
1515
.pipe(process.stdout)
1616

package-lock.json

Lines changed: 14 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"index.d.ts"
2121
],
2222
"engines": {
23-
"node": ">= 8.16.0"
23+
"node": ">= 10"
2424
},
2525
"scripts": {
2626
"bench": "bin/bench",
@@ -32,8 +32,7 @@
3232
"test": "ava && tsd"
3333
},
3434
"dependencies": {
35-
"minimist": "^1.2.0",
36-
"through2": "^3.0.1"
35+
"minimist": "^1.2.0"
3736
},
3837
"devDependencies": {
3938
"@commitlint/cli": "^8.2.0",

0 commit comments

Comments
 (0)