33const {
44 Array,
55 MathMin,
6- NumberIsInteger,
7- NumberIsSafeInteger,
86 ObjectDefineProperty,
97 ObjectSetPrototypeOf,
108 Symbol,
@@ -15,7 +13,7 @@ const {
1513 ERR_OUT_OF_RANGE ,
1614 ERR_STREAM_DESTROYED
1715} = require ( 'internal/errors' ) . codes ;
18- const { validateNumber } = require ( 'internal/validators' ) ;
16+ const { validateInteger } = require ( 'internal/validators' ) ;
1917const fs = require ( 'fs' ) ;
2018const { Buffer } = require ( 'buffer' ) ;
2119const {
@@ -46,19 +44,6 @@ function allocNewPool(poolSize) {
4644 pool . used = 0 ;
4745}
4846
49- // Check the `this.start` and `this.end` of stream.
50- function checkPosition ( pos , name ) {
51- if ( ! NumberIsSafeInteger ( pos ) ) {
52- validateNumber ( pos , name ) ;
53- if ( ! NumberIsInteger ( pos ) )
54- throw new ERR_OUT_OF_RANGE ( name , 'an integer' , pos ) ;
55- throw new ERR_OUT_OF_RANGE ( name , '>= 0 and <= 2 ** 53 - 1' , pos ) ;
56- }
57- if ( pos < 0 ) {
58- throw new ERR_OUT_OF_RANGE ( name , '>= 0 and <= 2 ** 53 - 1' , pos ) ;
59- }
60- }
61-
6247function roundUpToMultipleOf8 ( n ) {
6348 return ( n + 7 ) & ~ 7 ; // Align to 8 byte boundary.
6449}
@@ -111,15 +96,15 @@ function ReadStream(path, options) {
11196 this [ kIsPerformingIO ] = false ;
11297
11398 if ( this . start !== undefined ) {
114- checkPosition ( this . start , 'start' ) ;
99+ validateInteger ( this . start , 'start' , 0 ) ;
115100
116101 this . pos = this . start ;
117102 }
118103
119104 if ( this . end === undefined ) {
120105 this . end = Infinity ;
121106 } else if ( this . end !== Infinity ) {
122- checkPosition ( this . end , 'end' ) ;
107+ validateInteger ( this . end , 'end' , 0 ) ;
123108
124109 if ( this . start !== undefined && this . start > this . end ) {
125110 throw new ERR_OUT_OF_RANGE (
@@ -339,7 +324,7 @@ function WriteStream(path, options) {
339324 this [ kIsPerformingIO ] = false ;
340325
341326 if ( this . start !== undefined ) {
342- checkPosition ( this . start , 'start' ) ;
327+ validateInteger ( this . start , 'start' , 0 ) ;
343328
344329 this . pos = this . start ;
345330 }
0 commit comments