This repository was archived by the owner on Dec 21, 2021. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +14
-17
lines changed Expand file tree Collapse file tree 1 file changed +14
-17
lines changed Original file line number Diff line number Diff line change 11"use strict" ;
22
33( function ( ) {
4-
5- var debug
6- if ( typeof module !== 'undefined' ) {
7- debug = require ( 'debug' ) ( 'StreamrClient' )
8- } else {
9- debug = ( window . debug ? window . debug ( 'StreamrClient' ) : function ( ) {
10- if ( window . consoleLoggingEnabled )
11- console . log . apply ( console , arguments )
12- } )
13- }
144
15- var WebSocket
16- if ( typeof module !== 'undefined' ) {
17- WebSocket = require ( 'ws' )
18- } else {
19- WebSocket = window . WebSocket
20- }
21-
5+ /* <---
6+ Checking of the environment must be done with ternary operator instead of if-clause because of (possible) usage in Webpack.
7+ With if-clause, Webpack forces the code to use require, also in browser.
8+ Now it just works, in browser, in Node.js and in browser with Webpack. */
9+ var debug = ( typeof window !== 'undefined' && window . debug ) ? window . debug ( 'StreamrClient' ) : // If in browser and window.debug exists
10+ ( typeof require !== 'undefined' ? require ( 'debug' ) ( 'StreamrClient' ) : // Else if in node
11+ function ( ) { // Else use mock
12+ if ( window . consoleLoggingEnabled )
13+ console . log . apply ( console , arguments )
14+ } )
15+
16+ var WebSocket = typeof window !== 'undefined' ? window . WebSocket : require ( 'ws' )
17+ /* ---> */
18+
2219 var BYE_KEY = "_bye"
2320
2421 function extend ( ) {
You can’t perform that action at this time.
0 commit comments