1
1
var encoding = require ( 'encoding' ) ;
2
+ var {
3
+ Uint8Array,
4
+ ArrayBuffer,
5
+ TypedArrayPrototypeFill,
6
+ TypedArrayPrototypeCopyWithin,
7
+ TypedArrayPrototypeSet
8
+ } = require ( './internal/primordials.js' ) ;
2
9
3
10
const poolSize = 8 * 1024 ;
4
11
let poolOffset , allocPool ;
@@ -339,7 +346,7 @@ class Buffer extends Uint8Array {
339
346
if ( length !== buf_byteLength )
340
347
buf = new Uint8Array ( buf . buffer , buf . byteOffset , length ) ;
341
348
342
- this . set ( buf , offset ) ;
349
+ TypedArrayPrototypeSet ( this , buf , offset ) ;
343
350
344
351
return length ;
345
352
}
@@ -374,7 +381,7 @@ class Buffer extends Uint8Array {
374
381
throw new Error ( 'end < offset' ) ;
375
382
376
383
if ( typeof buf === 'number' ) {
377
- super . fill ( buf , offset , end ) ;
384
+ TypedArrayPrototypeFill ( this , buf , offset , end ) ;
378
385
return this ;
379
386
}
380
387
@@ -383,18 +390,18 @@ class Buffer extends Uint8Array {
383
390
if ( buf_byteLength >= end - offset ) {
384
391
if ( buf_byteLength > end - offset )
385
392
buf = new Uint8Array ( buf . buffer , buf . byteOffset , end - offset ) ;
386
- this . set ( buf , offset ) ;
393
+ TypedArrayPrototypeSet ( this , buf , offset ) ;
387
394
} else {
388
395
let fill_offset = offset ;
389
396
390
- this . set ( buf , offset ) ;
397
+ TypedArrayPrototypeSet ( this , buf , offset ) ;
391
398
offset += buf_byteLength ;
392
399
393
400
while ( offset < end ) {
394
401
if ( buf_byteLength > end - offset )
395
402
buf_byteLength = end - offset ;
396
403
397
- this . copyWithin ( offset , fill_offset , fill_offset + buf_byteLength ) ;
404
+ TypedArrayPrototypeCopyWithin ( this , offset , fill_offset , fill_offset + buf_byteLength ) ;
398
405
offset += buf_byteLength ;
399
406
400
407
buf_byteLength *= 2 ;
@@ -1145,7 +1152,7 @@ class Buffer extends Uint8Array {
1145
1152
if ( sourceStart != 0 || sourceEnd != buf . byteLength )
1146
1153
buf = new Uint8Array ( buf . buffer , buf . byteOffset + sourceStart , sourceEnd - sourceStart ) ;
1147
1154
1148
- target . set ( buf , targetStart ) ;
1155
+ TypedArrayPrototypeSet ( target , buf , targetStart ) ;
1149
1156
1150
1157
return sourceEnd - sourceStart ;
1151
1158
@@ -1292,7 +1299,7 @@ Buffer.concat = function (list, length) {
1292
1299
buf_byteLength = length - pos ;
1293
1300
}
1294
1301
1295
- buffer . set ( buf , pos ) ;
1302
+ TypedArrayPrototypeSet ( buffer , buf , pos ) ;
1296
1303
pos += buf_byteLength ;
1297
1304
}
1298
1305
0 commit comments