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) {
115115 } else {
116116 return (
117117 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
119122 ) ;
120123 }
121124}
Original file line number Diff line number Diff line change @@ -175,6 +175,9 @@ if (isBuggyFirefox) {
175175 console . log ( 'skipping fake typed array tests because they do not work in FF' )
176176}
177177
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 ;
178181{
179182 var primitive = function primitive ( ) { return true ; } ;
180183 var arrayBuffer = function arrayBuffer ( ) { return new ArrayBuffer ( 1 ) ; } ;
@@ -394,7 +397,7 @@ if (isBuggyFirefox) {
394397
395398 var expected = {
396399 isArrayBufferView : [
397- buffer ,
400+ isBufferBasedOnArrayBuffer ? buffer : undefined ,
398401 dataView ,
399402 stealthyDataView ,
400403 uint8Array ,
@@ -421,7 +424,7 @@ if (isBuggyFirefox) {
421424 stealthyBigUint64Array
422425 ] ,
423426 isTypedArray : [
424- buffer ,
427+ isBufferBasedOnArrayBuffer ? buffer : undefined ,
425428 uint8Array ,
426429 stealthyUint8Array ,
427430 uint8ClampedArray ,
@@ -446,7 +449,7 @@ if (isBuggyFirefox) {
446449 stealthyBigUint64Array
447450 ] ,
448451 isUint8Array : [
449- buffer ,
452+ isBufferBasedOnArrayBuffer ? buffer : undefined ,
450453 uint8Array ,
451454 stealthyUint8Array
452455 ] ,
You can’t perform that action at this time.
0 commit comments