Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: remove hasBufferModule code #196

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 2 additions & 16 deletions packages/rsocket-core/src/LiteBuffer.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import ExistingBufferModule from 'buffer';

const hasGlobalBuffer =
typeof global !== 'undefined' && global.hasOwnProperty('Buffer');
const hasBufferModule = ExistingBufferModule.hasOwnProperty('Buffer');


function notImplemented(msg?: string): void {
const message = msg ? `Not implemented: ${msg}` : 'Not implemented';
Expand Down Expand Up @@ -605,10 +605,7 @@ export class Buffer extends Uint8Array {
* Returns true if obj is a Buffer, false otherwise.
*/
static isBuffer(obj: any): boolean {
return (
isInstance(obj, Buffer) ||
(!hasGlobalBuffer && hasBufferModule && isInstance(obj, Uint8Array))
);
return isInstance(obj, Buffer);
}

static isEncoding(encoding: any): boolean {
Expand Down Expand Up @@ -996,17 +993,6 @@ export class Buffer extends Uint8Array {
}

if (!hasGlobalBuffer) {
if (hasBufferModule) {
// ExistingBuffer is likely to be a polyfill, hence we can override it
// eslint-disable-next-line no-undef
// $FlowFixMe
Object.defineProperty(ExistingBufferModule, 'Buffer', {
configurable: true,
enumerable: false,
value: Buffer,
writable: true,
});
}
// eslint-disable-next-line no-undef
Object.defineProperty(window, 'Buffer', {
configurable: true,
Expand Down