3
3
const {
4
4
Array,
5
5
MathMin,
6
- NumberIsInteger,
7
- NumberIsSafeInteger,
8
6
ObjectDefineProperty,
9
7
ObjectSetPrototypeOf,
10
8
Symbol,
@@ -16,7 +14,7 @@ const {
16
14
ERR_STREAM_DESTROYED
17
15
} = require ( 'internal/errors' ) . codes ;
18
16
const { deprecate } = require ( 'internal/util' ) ;
19
- const { validateNumber } = require ( 'internal/validators' ) ;
17
+ const { validateInteger } = require ( 'internal/validators' ) ;
20
18
const fs = require ( 'fs' ) ;
21
19
const { Buffer } = require ( 'buffer' ) ;
22
20
const {
@@ -47,19 +45,6 @@ function allocNewPool(poolSize) {
47
45
pool . used = 0 ;
48
46
}
49
47
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
-
63
48
function roundUpToMultipleOf8 ( n ) {
64
49
return ( n + 7 ) & ~ 7 ; // Align to 8 byte boundary.
65
50
}
@@ -111,15 +96,15 @@ function ReadStream(path, options) {
111
96
this [ kIsPerformingIO ] = false ;
112
97
113
98
if ( this . start !== undefined ) {
114
- checkPosition ( this . start , 'start' ) ;
99
+ validateInteger ( this . start , 'start' , 0 ) ;
115
100
116
101
this . pos = this . start ;
117
102
}
118
103
119
104
if ( this . end === undefined ) {
120
105
this . end = Infinity ;
121
106
} else if ( this . end !== Infinity ) {
122
- checkPosition ( this . end , 'end' ) ;
107
+ validateInteger ( this . end , 'end' , 0 ) ;
123
108
124
109
if ( this . start !== undefined && this . start > this . end ) {
125
110
throw new ERR_OUT_OF_RANGE (
@@ -346,7 +331,7 @@ function WriteStream(path, options) {
346
331
this [ kIsPerformingIO ] = false ;
347
332
348
333
if ( this . start !== undefined ) {
349
- checkPosition ( this . start , 'start' ) ;
334
+ validateInteger ( this . start , 'start' , 0 ) ;
350
335
351
336
this . pos = this . start ;
352
337
}
0 commit comments