Skip to content

Commit

Permalink
refactor!: drop through2 (#178)
Browse files Browse the repository at this point in the history
Ref https://github.com/rvagg/through2#do-you-need-this
Closes #177

BREAKING CHANGES: Require node 10 and higher.
  • Loading branch information
TrySound authored Sep 29, 2020
1 parent a72f822 commit a0fca5d
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 24 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
language: node_js
node_js:
- 14
- 12
- 10
- 8
script:
- 'npm run lint'
- 'npm run test'
Expand Down
11 changes: 7 additions & 4 deletions bin/csv-parser
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

const { EOL } = require('os')
const minimist = require('minimist')
const through = require('through2')
const { Transform } = require('stream');
const fs = require('fs')
const csv = require('../')
const pkg = require('../package.json')
Expand Down Expand Up @@ -80,9 +80,12 @@ if (filename === '-' || !filename) {
}

const serialize = () => {
return through.obj((obj, enc, cb) => {
cb(null, JSON.stringify(obj) + EOL)
})
return new Transform({
objectMode: true,
transform(obj, enc, cb) {
cb(null, JSON.stringify(obj) + EOL)
}
});
}

input
Expand Down
4 changes: 2 additions & 2 deletions examples/transform.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const write = require('csv-write-stream')
const through = require('through2')
const { Transform } = require('stream')
const parse = require('../')
const path = require('path')
const fs = require('fs')
Expand All @@ -10,7 +10,7 @@ const fs = require('fs')
// .pipe(fs.createWriteStream('./file'))
fs.createReadStream(path.join(__dirname, '../test/data/dummy.csv'))
.pipe(parse())
.pipe(through.obj(transform))
.pipe(new Transform({ objectMode: true, transform }))
.pipe(write())
.pipe(process.stdout)

Expand Down
28 changes: 14 additions & 14 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"index.d.ts"
],
"engines": {
"node": ">= 8.16.0"
"node": ">= 10"
},
"scripts": {
"bench": "bin/bench",
Expand All @@ -32,8 +32,7 @@
"test": "ava && tsd"
},
"dependencies": {
"minimist": "^1.2.0",
"through2": "^3.0.1"
"minimist": "^1.2.0"
},
"devDependencies": {
"@commitlint/cli": "^8.2.0",
Expand Down

0 comments on commit a0fca5d

Please sign in to comment.