@@ -69,7 +69,6 @@ const {
69
69
ERR_INVALID_ARG_TYPE ,
70
70
ERR_INVALID_CALLBACK ,
71
71
ERR_FEATURE_UNAVAILABLE_ON_PLATFORM ,
72
- ERR_OUT_OF_RANGE ,
73
72
} ,
74
73
hideStackFrames,
75
74
uvErrmapGet,
@@ -99,6 +98,7 @@ const {
99
98
validateOffsetLengthRead,
100
99
validateOffsetLengthWrite,
101
100
validatePath,
101
+ validatePosition,
102
102
validateRmOptions,
103
103
validateRmOptionsSync,
104
104
validateRmdirOptions,
@@ -556,19 +556,7 @@ function read(fd, buffer, offset, length, position, callback) {
556
556
if ( position == null )
557
557
position = - 1 ;
558
558
559
- if ( typeof position === 'number' ) {
560
- validateInteger ( position , 'position' ) ;
561
- } else if ( typeof position === 'bigint' ) {
562
- if ( ! ( position >= - ( 2n ** 63n ) && position <= 2n ** 63n - 1n ) ) {
563
- throw new ERR_OUT_OF_RANGE ( 'position' ,
564
- `>= ${ - ( 2n ** 63n ) } && <= ${ 2n ** 63n - 1n } ` ,
565
- position ) ;
566
- }
567
- } else {
568
- throw new ERR_INVALID_ARG_TYPE ( 'position' ,
569
- [ 'integer' , 'bigint' ] ,
570
- position ) ;
571
- }
559
+ validatePosition ( position , 'position' ) ;
572
560
573
561
function wrapper ( err , bytesRead ) {
574
562
// Retain a reference to buffer so that it can't be GC'ed too soon.
@@ -622,19 +610,7 @@ function readSync(fd, buffer, offset, length, position) {
622
610
if ( position == null )
623
611
position = - 1 ;
624
612
625
- if ( typeof position === 'number' ) {
626
- validateInteger ( position , 'position' ) ;
627
- } else if ( typeof position === 'bigint' ) {
628
- if ( ! ( position >= - ( 2n ** 63n ) && position <= 2n ** 63n - 1n ) ) {
629
- throw new ERR_OUT_OF_RANGE ( 'position' ,
630
- `>= ${ - ( 2n ** 63n ) } && <= ${ 2n ** 63n - 1n } ` ,
631
- position ) ;
632
- }
633
- } else {
634
- throw new ERR_INVALID_ARG_TYPE ( 'position' ,
635
- [ 'integer' , 'bigint' ] ,
636
- position ) ;
637
- }
613
+ validatePosition ( position , 'position' ) ;
638
614
639
615
const ctx = { } ;
640
616
const result = binding . read ( fd , buffer , offset , length , position ,
0 commit comments