@@ -30,6 +30,7 @@ const {
3030 MathFloor,
3131 MathMin,
3232 MathTrunc,
33+ NumberIsInteger,
3334 NumberIsNaN,
3435 NumberMAX_SAFE_INTEGER,
3536 NumberMIN_SAFE_INTEGER,
@@ -212,30 +213,27 @@ function _copy(source, target, targetStart, sourceStart, sourceEnd) {
212213 if ( targetStart === undefined ) {
213214 targetStart = 0 ;
214215 } else {
215- targetStart = toInteger ( targetStart , 0 ) ;
216+ targetStart = NumberIsInteger ( targetStart ) ? targetStart : toInteger ( targetStart , 0 ) ;
216217 if ( targetStart < 0 )
217218 throw new ERR_OUT_OF_RANGE ( 'targetStart' , '>= 0' , targetStart ) ;
218219 }
219220
220221 if ( sourceStart === undefined ) {
221222 sourceStart = 0 ;
222223 } else {
223- sourceStart = toInteger ( sourceStart , 0 ) ;
224+ sourceStart = NumberIsInteger ( targetStart ) ? targetStart : toInteger ( sourceStart , 0 ) ;
224225 if ( sourceStart < 0 || sourceStart > source . length )
225226 throw new ERR_OUT_OF_RANGE ( 'sourceStart' , `>= 0 && <= ${ source . length } ` , sourceStart ) ;
226227 }
227228
228229 if ( sourceEnd === undefined ) {
229230 sourceEnd = source . length ;
230231 } else {
231- sourceEnd = toInteger ( sourceEnd , 0 ) ;
232+ sourceEnd = NumberIsInteger ( sourceEnd ) ? sourceEnd : toInteger ( sourceEnd , 0 ) ;
232233 if ( sourceEnd < 0 )
233234 throw new ERR_OUT_OF_RANGE ( 'sourceEnd' , '>= 0' , sourceEnd ) ;
234235 }
235236
236- if ( targetStart >= target . length || sourceStart >= sourceEnd )
237- return 0 ;
238-
239237 return _copyActual ( source , target , targetStart , sourceStart , sourceEnd ) ;
240238}
241239
@@ -248,6 +246,9 @@ function _copyActual(source, target, targetStart, sourceStart, sourceEnd) {
248246 if ( nb > sourceLen )
249247 nb = sourceLen ;
250248
249+ if ( nb === 0 )
250+ return 0 ;
251+
251252 if ( sourceStart !== 0 || sourceEnd < source . length )
252253 source = new Uint8Array ( source . buffer , source . byteOffset + sourceStart , nb ) ;
253254
0 commit comments