File tree Expand file tree Collapse file tree 2 files changed +14
-6
lines changed Expand file tree Collapse file tree 2 files changed +14
-6
lines changed Original file line number Diff line number Diff line change 44import type { Buffer as NodeBuffer } from 'buffer' ;
55import ExistingBufferModule from 'buffer' ;
66
7- const bufferExists =
7+ const hasGlobalBuffer =
88 typeof global !== 'undefined' && global . hasOwnProperty ( 'Buffer' ) ;
9+ const hasBufferModule = ExistingBufferModule . hasOwnProperty ( 'Buffer' ) ;
910
1011function notImplemented ( msg ?: string ) : void {
1112 const message = msg ? `Not implemented: ${ msg } ` : 'Not implemented' ;
@@ -604,7 +605,10 @@ export class Buffer extends Uint8Array {
604605 * Returns true if obj is a Buffer, false otherwise.
605606 */
606607 static isBuffer ( obj : any ) : boolean {
607- return isInstance ( obj , Buffer ) ;
608+ return (
609+ isInstance ( obj , Buffer ) ||
610+ ( ! hasGlobalBuffer && hasBufferModule && isInstance ( obj , Uint8Array ) )
611+ ) ;
608612 }
609613
610614 static isEncoding ( encoding : any ) : boolean {
@@ -991,8 +995,8 @@ export class Buffer extends Uint8Array {
991995 }
992996}
993997
994- if ( ! bufferExists ) {
995- if ( ExistingBufferModule . hasOwnProperty ( ' Buffer ' ) ) {
998+ if ( ! hasGlobalBuffer ) {
999+ if ( hasBufferModule ) {
9961000 // ExistingBuffer is likely to be a polyfill, hence we can override it
9971001 // eslint-disable-next-line no-undef
9981002 // $FlowFixMe
@@ -1012,4 +1016,4 @@ if (!bufferExists) {
10121016 } ) ;
10131017}
10141018
1015- export const LiteBuffer : NodeBuffer = bufferExists ? global . Buffer : Buffer ;
1019+ export const LiteBuffer : NodeBuffer = hasGlobalBuffer ? global . Buffer : Buffer ;
Original file line number Diff line number Diff line change 1717
1818'use strict' ;
1919
20- import { RSocketTcpClient , RSocketTcpConnection , RSocketTlsClient } from './RSocketTcpClient' ;
20+ import {
21+ RSocketTcpClient ,
22+ RSocketTcpConnection ,
23+ RSocketTlsClient ,
24+ } from './RSocketTcpClient' ;
2125export default RSocketTcpClient ;
2226export { RSocketTcpConnection , RSocketTlsClient } ;
You can’t perform that action at this time.
0 commit comments