11'use strict' ;
2- var common = require ( '../common' ) ;
3- var assert = require ( 'assert' ) ;
2+ const common = require ( '../common' ) ;
3+ const assert = require ( 'assert' ) ;
44
5- var path = require ( 'path' ) ;
6- var fs = require ( 'fs' ) ;
7- var fn = path . join ( common . fixturesDir , 'elipses.txt' ) ;
8- var rangeFile = path . join ( common . fixturesDir , 'x.txt' ) ;
5+ const path = require ( 'path' ) ;
6+ const fs = require ( 'fs' ) ;
7+ const fn = path . join ( common . fixturesDir , 'elipses.txt' ) ;
8+ const rangeFile = path . join ( common . fixturesDir , 'x.txt' ) ;
99
10- var callbacks = { open : 0 , end : 0 , close : 0 } ;
10+ const callbacks = { open : 0 , end : 0 , close : 0 } ;
1111
12- var paused = false ;
12+ let paused = false ;
1313
14- var file = fs . ReadStream ( fn ) ;
14+ const file = fs . ReadStream ( fn ) ;
1515
1616file . on ( 'open' , function ( fd ) {
1717 file . length = 0 ;
1818 callbacks . open ++ ;
19- assert . equal ( 'number' , typeof fd ) ;
19+ assert . strictEqual ( typeof fd , 'number' ) ;
2020 assert . ok ( file . readable ) ;
2121
2222 // GH-535
@@ -48,19 +48,17 @@ file.on('end', function(chunk) {
4848
4949file . on ( 'close' , function ( ) {
5050 callbacks . close ++ ;
51-
52- //assert.equal(fs.readFileSync(fn), fileContent);
5351} ) ;
5452
55- var file3 = fs . createReadStream ( fn , Object . create ( { encoding : 'utf8' } ) ) ;
53+ const file3 = fs . createReadStream ( fn , Object . create ( { encoding : 'utf8' } ) ) ;
5654file3 . length = 0 ;
5755file3 . on ( 'data' , function ( data ) {
58- assert . equal ( 'string' , typeof data ) ;
56+ assert . strictEqual ( typeof data , 'string' ) ;
5957 file3 . length += data . length ;
6058
61- for ( var i = 0 ; i < data . length ; i ++ ) {
59+ for ( let i = 0 ; i < data . length ; i ++ ) {
6260 // http://www.fileformat.info/info/unicode/char/2026/index.htm
63- assert . equal ( '\u2026' , data [ i ] ) ;
61+ assert . strictEqual ( data [ i ] , '\u2026' ) ;
6462 }
6563} ) ;
6664
@@ -69,74 +67,74 @@ file3.on('close', function() {
6967} ) ;
7068
7169process . on ( 'exit' , function ( ) {
72- assert . equal ( 1 , callbacks . open ) ;
73- assert . equal ( 1 , callbacks . end ) ;
74- assert . equal ( 2 , callbacks . close ) ;
75- assert . equal ( 30000 , file . length ) ;
76- assert . equal ( 10000 , file3 . length ) ;
70+ assert . strictEqual ( callbacks . open , 1 ) ;
71+ assert . strictEqual ( callbacks . end , 1 ) ;
72+ assert . strictEqual ( callbacks . close , 2 ) ;
73+ assert . strictEqual ( file . length , 30000 ) ;
74+ assert . strictEqual ( file3 . length , 10000 ) ;
7775 console . error ( 'ok' ) ;
7876} ) ;
7977
80- var file4 = fs . createReadStream ( rangeFile , Object . create ( { bufferSize : 1 ,
81- start : 1 , end : 2 } ) ) ;
82- assert . equal ( file4 . start , 1 ) ;
83- assert . equal ( file4 . end , 2 ) ;
84- var contentRead = '' ;
78+ const file4 = fs . createReadStream ( rangeFile , Object . create ( { bufferSize : 1 ,
79+ start : 1 , end : 2 } ) ) ;
80+ assert . strictEqual ( file4 . start , 1 ) ;
81+ assert . strictEqual ( file4 . end , 2 ) ;
82+ let contentRead = '' ;
8583file4 . on ( 'data' , function ( data ) {
8684 contentRead += data . toString ( 'utf-8' ) ;
8785} ) ;
8886file4 . on ( 'end' , function ( data ) {
89- assert . equal ( contentRead , 'yz' ) ;
87+ assert . strictEqual ( contentRead , 'yz' ) ;
9088} ) ;
9189
92- var file5 = fs . createReadStream ( rangeFile , Object . create ( { bufferSize : 1 ,
93- start : 1 } ) ) ;
94- assert . equal ( file5 . start , 1 ) ;
90+ const file5 = fs . createReadStream ( rangeFile , Object . create ( { bufferSize : 1 ,
91+ start : 1 } ) ) ;
92+ assert . strictEqual ( file5 . start , 1 ) ;
9593file5 . data = '' ;
9694file5 . on ( 'data' , function ( data ) {
9795 file5 . data += data . toString ( 'utf-8' ) ;
9896} ) ;
9997file5 . on ( 'end' , function ( ) {
100- assert . equal ( file5 . data , 'yz\n' ) ;
98+ assert . strictEqual ( file5 . data , 'yz\n' ) ;
10199} ) ;
102100
103101// https://github.com/joyent/node/issues/2320
104- var file6 = fs . createReadStream ( rangeFile , Object . create ( { bufferSize : 1.23 ,
105- start : 1 } ) ) ;
106- assert . equal ( file6 . start , 1 ) ;
102+ const file6 = fs . createReadStream ( rangeFile , Object . create ( { bufferSize : 1.23 ,
103+ start : 1 } ) ) ;
104+ assert . strictEqual ( file6 . start , 1 ) ;
107105file6 . data = '' ;
108106file6 . on ( 'data' , function ( data ) {
109107 file6 . data += data . toString ( 'utf-8' ) ;
110108} ) ;
111109file6 . on ( 'end' , function ( ) {
112- assert . equal ( file6 . data , 'yz\n' ) ;
110+ assert . strictEqual ( file6 . data , 'yz\n' ) ;
113111} ) ;
114112
115113assert . throws ( function ( ) {
116114 fs . createReadStream ( rangeFile , Object . create ( { start : 10 , end : 2 } ) ) ;
117115} , / s t a r t m u s t b e < = e n d / ) ;
118116
119- var stream = fs . createReadStream ( rangeFile , Object . create ( { start : 0 ,
120- end : 0 } ) ) ;
121- assert . equal ( stream . start , 0 ) ;
122- assert . equal ( stream . end , 0 ) ;
117+ const stream = fs . createReadStream ( rangeFile , Object . create ( { start : 0 ,
118+ end : 0 } ) ) ;
119+ assert . strictEqual ( stream . start , 0 ) ;
120+ assert . strictEqual ( stream . end , 0 ) ;
123121stream . data = '' ;
124122
125123stream . on ( 'data' , function ( chunk ) {
126124 stream . data += chunk ;
127125} ) ;
128126
129127stream . on ( 'end' , function ( ) {
130- assert . equal ( 'x' , stream . data ) ;
128+ assert . strictEqual ( stream . data , 'x' ) ;
131129} ) ;
132130
133131// pause and then resume immediately.
134- var pauseRes = fs . createReadStream ( rangeFile ) ;
132+ const pauseRes = fs . createReadStream ( rangeFile ) ;
135133pauseRes . pause ( ) ;
136134pauseRes . resume ( ) ;
137135
138- var file7 = fs . createReadStream ( rangeFile , Object . create ( { autoClose : false } ) ) ;
139- assert . equal ( file7 . autoClose , false ) ;
136+ let file7 = fs . createReadStream ( rangeFile , Object . create ( { autoClose : false } ) ) ;
137+ assert . strictEqual ( file7 . autoClose , false ) ;
140138file7 . on ( 'data' , function ( ) { } ) ;
141139file7 . on ( 'end' , function ( ) {
142140 process . nextTick ( function ( ) {
@@ -154,18 +152,18 @@ function file7Next() {
154152 file7 . data += data ;
155153 } ) ;
156154 file7 . on ( 'end' , function ( err ) {
157- assert . equal ( file7 . data , 'xyz\n' ) ;
155+ assert . strictEqual ( file7 . data , 'xyz\n' ) ;
158156 } ) ;
159157}
160158
161159// Just to make sure autoClose won't close the stream because of error.
162- var file8 = fs . createReadStream ( null , Object . create ( { fd : 13337 ,
163- autoClose : false } ) ) ;
160+ const file8 = fs . createReadStream ( null , Object . create ( { fd : 13337 ,
161+ autoClose : false } ) ) ;
164162file8 . on ( 'data' , function ( ) { } ) ;
165163file8 . on ( 'error' , common . mustCall ( function ( ) { } ) ) ;
166164
167165// Make sure stream is destroyed when file does not exist.
168- var file9 = fs . createReadStream ( '/path/to/file/that/does/not/exist' ) ;
166+ const file9 = fs . createReadStream ( '/path/to/file/that/does/not/exist' ) ;
169167file9 . on ( 'data' , function ( ) { } ) ;
170168file9 . on ( 'error' , common . mustCall ( function ( ) { } ) ) ;
171169
0 commit comments