@@ -75,7 +75,6 @@ const {
75
75
ERR_INVALID_ARG_VALUE ,
76
76
ERR_INVALID_ARG_TYPE ,
77
77
ERR_FEATURE_UNAVAILABLE_ON_PLATFORM ,
78
- ERR_OUT_OF_RANGE ,
79
78
} ,
80
79
hideStackFrames,
81
80
uvErrmapGet,
@@ -105,6 +104,7 @@ const {
105
104
validateOffsetLengthRead,
106
105
validateOffsetLengthWrite,
107
106
validatePath,
107
+ validatePosition,
108
108
validateRmOptions,
109
109
validateRmOptionsSync,
110
110
validateRmdirOptions,
@@ -550,19 +550,7 @@ function read(fd, buffer, offset, length, position, callback) {
550
550
if ( position == null )
551
551
position = - 1 ;
552
552
553
- if ( typeof position === 'number' ) {
554
- validateInteger ( position , 'position' ) ;
555
- } else if ( typeof position === 'bigint' ) {
556
- if ( ! ( position >= - ( 2n ** 63n ) && position <= 2n ** 63n - 1n ) ) {
557
- throw new ERR_OUT_OF_RANGE ( 'position' ,
558
- `>= ${ - ( 2n ** 63n ) } && <= ${ 2n ** 63n - 1n } ` ,
559
- position ) ;
560
- }
561
- } else {
562
- throw new ERR_INVALID_ARG_TYPE ( 'position' ,
563
- [ 'integer' , 'bigint' ] ,
564
- position ) ;
565
- }
553
+ validatePosition ( position , 'position' ) ;
566
554
567
555
function wrapper ( err , bytesRead ) {
568
556
// Retain a reference to buffer so that it can't be GC'ed too soon.
@@ -616,19 +604,7 @@ function readSync(fd, buffer, offset, length, position) {
616
604
if ( position == null )
617
605
position = - 1 ;
618
606
619
- if ( typeof position === 'number' ) {
620
- validateInteger ( position , 'position' ) ;
621
- } else if ( typeof position === 'bigint' ) {
622
- if ( ! ( position >= - ( 2n ** 63n ) && position <= 2n ** 63n - 1n ) ) {
623
- throw new ERR_OUT_OF_RANGE ( 'position' ,
624
- `>= ${ - ( 2n ** 63n ) } && <= ${ 2n ** 63n - 1n } ` ,
625
- position ) ;
626
- }
627
- } else {
628
- throw new ERR_INVALID_ARG_TYPE ( 'position' ,
629
- [ 'integer' , 'bigint' ] ,
630
- position ) ;
631
- }
607
+ validatePosition ( position , 'position' ) ;
632
608
633
609
const ctx = { } ;
634
610
const result = binding . read ( fd , buffer , offset , length , position ,
0 commit comments