3
3
const {
4
4
Array,
5
5
MathMin,
6
- NumberIsInteger,
7
- NumberIsSafeInteger,
8
6
ObjectDefineProperty,
9
7
ObjectSetPrototypeOf,
10
8
Symbol,
@@ -15,7 +13,7 @@ const {
15
13
ERR_OUT_OF_RANGE ,
16
14
ERR_STREAM_DESTROYED
17
15
} = require ( 'internal/errors' ) . codes ;
18
- const { validateNumber } = require ( 'internal/validators' ) ;
16
+ const { validateInteger } = require ( 'internal/validators' ) ;
19
17
const fs = require ( 'fs' ) ;
20
18
const { Buffer } = require ( 'buffer' ) ;
21
19
const {
@@ -46,19 +44,6 @@ function allocNewPool(poolSize) {
46
44
pool . used = 0 ;
47
45
}
48
46
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
-
62
47
function roundUpToMultipleOf8 ( n ) {
63
48
return ( n + 7 ) & ~ 7 ; // Align to 8 byte boundary.
64
49
}
@@ -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 (
@@ -339,7 +324,7 @@ function WriteStream(path, options) {
339
324
this [ kIsPerformingIO ] = false ;
340
325
341
326
if ( this . start !== undefined ) {
342
- checkPosition ( this . start , 'start' ) ;
327
+ validateInteger ( this . start , 'start' , 0 ) ;
343
328
344
329
this . pos = this . start ;
345
330
}
0 commit comments