File tree Expand file tree Collapse file tree 2 files changed +10
-4
lines changed Expand file tree Collapse file tree 2 files changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -115,7 +115,10 @@ function isUint8Array(value) {
115
115
} else {
116
116
return (
117
117
ObjectToString ( value ) === '[object Uint8Array]' ||
118
- isBuffer ( value )
118
+ // If it's a Buffer instance _and_ has a `.buffer` property,
119
+ // this is an ArrayBuffer based buffer; thus it's an Uint8Array
120
+ // (Old Node.js had a custom non-Uint8Array implementation)
121
+ isBuffer ( value ) && value . buffer !== undefined
119
122
) ;
120
123
}
121
124
}
Original file line number Diff line number Diff line change @@ -175,6 +175,9 @@ if (isBuggyFirefox) {
175
175
console . log ( 'skipping fake typed array tests because they do not work in FF' )
176
176
}
177
177
178
+ // Old Node.js had a fully custom Buffer implementation, newer are based on ArrayBuffer
179
+ // This is important for the ArrayBuffer and typed array tests
180
+ var isBufferBasedOnArrayBuffer = Buffer . alloc ( 1 ) . buffer !== undefined ;
178
181
{
179
182
var primitive = function primitive ( ) { return true ; } ;
180
183
var arrayBuffer = function arrayBuffer ( ) { return new ArrayBuffer ( 1 ) ; } ;
@@ -394,7 +397,7 @@ if (isBuggyFirefox) {
394
397
395
398
var expected = {
396
399
isArrayBufferView : [
397
- buffer ,
400
+ isBufferBasedOnArrayBuffer ? buffer : undefined ,
398
401
dataView ,
399
402
stealthyDataView ,
400
403
uint8Array ,
@@ -421,7 +424,7 @@ if (isBuggyFirefox) {
421
424
stealthyBigUint64Array
422
425
] ,
423
426
isTypedArray : [
424
- buffer ,
427
+ isBufferBasedOnArrayBuffer ? buffer : undefined ,
425
428
uint8Array ,
426
429
stealthyUint8Array ,
427
430
uint8ClampedArray ,
@@ -446,7 +449,7 @@ if (isBuggyFirefox) {
446
449
stealthyBigUint64Array
447
450
] ,
448
451
isUint8Array : [
449
- buffer ,
452
+ isBufferBasedOnArrayBuffer ? buffer : undefined ,
450
453
uint8Array ,
451
454
stealthyUint8Array
452
455
] ,
You can’t perform that action at this time.
0 commit comments