Skip to content

Commit 0293a9e

Browse files
oprogramadorrvagg
authored andcommitted
replace function into arrow function in README
1 parent 40d2668 commit 0293a9e

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

Diff for: README.md

+5-7
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,7 @@ fs.createReadStream('ex.txt')
2020
callback()
2121
}))
2222
.pipe(fs.createWriteStream('out.txt'))
23-
.on('finish', function () {
24-
doSomethingSpecial()
25-
})
23+
.on('finish', () => doSomethingSpecial())
2624
```
2725

2826
Or object streams:
@@ -42,10 +40,10 @@ fs.createReadStream('data.csv')
4240

4341
callback()
4442
}))
45-
.on('data', function (data) {
43+
.on('data', (data) => {
4644
all.push(data)
4745
})
48-
.on('end', function () {
46+
.on('end', () => {
4947
doSomethingSpecial(all)
5048
})
5149
```
@@ -67,7 +65,7 @@ The `options` argument is first, unlike standard convention, because if I'm pass
6765
```js
6866
fs.createReadStream('/tmp/important.dat')
6967
.pipe(through2({ objectMode: true, allowHalfOpen: false },
70-
function (chunk, enc, cb) {
68+
(chunk, enc, cb) => {
7169
cb(null, 'wut?') // note we can use the second argument on the callback
7270
// to provide data as an alternative to this.push('wut?')
7371
}
@@ -92,7 +90,7 @@ The optional `flushFunction` is provided as the last argument (2nd or 3rd, depen
9290
```js
9391
fs.createReadStream('/tmp/important.dat')
9492
.pipe(through2(
95-
function (chunk, enc, cb) { cb(null, chunk) }, // transform is a noop
93+
(chunk, enc, cb) => cb(null, chunk), // transform is a noop
9694
function (cb) { // flush function
9795
this.push('tacking on an extra buffer to the end');
9896
cb();

0 commit comments

Comments
 (0)