forked from tanishkothari9/quickloop
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathshim.js
More file actions
24 lines (20 loc) · 635 Bytes
/
shim.js
File metadata and controls
24 lines (20 loc) · 635 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
// Polyfills for Node.js modules
import { Buffer } from 'buffer';
import process from 'process';
import EventEmitter from 'events';
// Import our WebSocket mock
import { WebSocket, WebSocketServer } from './mocks/ws';
// Make these available globally
if (typeof global !== 'undefined') {
global.Buffer = Buffer;
global.process = process;
global.EventEmitter = EventEmitter;
// Mock WebSocket
global.WebSocket = global.WebSocket || WebSocket;
global.WebSocketServer = global.WebSocketServer || WebSocketServer;
// Mock empty modules
global.http = {};
global.https = {};
global.net = {};
global.tls = {};
}