33const {
44 Array,
55 MathMin,
6- NumberIsInteger,
7- NumberIsSafeInteger,
86 ObjectDefineProperty,
97 ObjectSetPrototypeOf,
108 Symbol,
@@ -16,7 +14,7 @@ const {
1614 ERR_STREAM_DESTROYED
1715} = require ( 'internal/errors' ) . codes ;
1816const { deprecate } = require ( 'internal/util' ) ;
19- const { validateNumber } = require ( 'internal/validators' ) ;
17+ const { validateInteger } = require ( 'internal/validators' ) ;
2018const fs = require ( 'fs' ) ;
2119const { Buffer } = require ( 'buffer' ) ;
2220const {
@@ -47,19 +45,6 @@ function allocNewPool(poolSize) {
4745 pool . used = 0 ;
4846}
4947
50- // Check the `this.start` and `this.end` of stream.
51- function checkPosition ( pos , name ) {
52- if ( ! NumberIsSafeInteger ( pos ) ) {
53- validateNumber ( pos , name ) ;
54- if ( ! NumberIsInteger ( pos ) )
55- throw new ERR_OUT_OF_RANGE ( name , 'an integer' , pos ) ;
56- throw new ERR_OUT_OF_RANGE ( name , '>= 0 and <= 2 ** 53 - 1' , pos ) ;
57- }
58- if ( pos < 0 ) {
59- throw new ERR_OUT_OF_RANGE ( name , '>= 0 and <= 2 ** 53 - 1' , pos ) ;
60- }
61- }
62-
6348function roundUpToMultipleOf8 ( n ) {
6449 return ( n + 7 ) & ~ 7 ; // Align to 8 byte boundary.
6550}
@@ -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 (
@@ -346,7 +331,7 @@ function WriteStream(path, options) {
346331 this [ kIsPerformingIO ] = false ;
347332
348333 if ( this . start !== undefined ) {
349- checkPosition ( this . start , 'start' ) ;
334+ validateInteger ( this . start , 'start' , 0 ) ;
350335
351336 this . pos = this . start ;
352337 }
0 commit comments