- Timestamp:
- 11/25/21 22:08:24 (3 years ago)
- Branches:
- master
- Children:
- 8d391a1
- Parents:
- 59329aa
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trip-planner-front/node_modules/ws/lib/event-target.js
r59329aa re29cc2e 11 11 * 12 12 * @param {String} type The name of the event 13 * @param {Object} target A reference to the target to which the event was 14 * dispatched 13 * @param {Object} target A reference to the target to which the event was dispatched 15 14 */ 16 15 constructor(type, target) { … … 31 30 * 32 31 * @param {(String|Buffer|ArrayBuffer|Buffer[])} data The received data 33 * @param {WebSocket} target A reference to the target to which the event was 34 * dispatched 32 * @param {WebSocket} target A reference to the target to which the event was dispatched 35 33 */ 36 34 constructor(data, target) { … … 51 49 * Create a new `CloseEvent`. 52 50 * 53 * @param {Number} code The status code explaining why the connection is being 54 * closed 55 * @param {String} reason A human-readable string explaining why the 56 * connection is closing 57 * @param {WebSocket} target A reference to the target to which the event was 58 * dispatched 51 * @param {Number} code The status code explaining why the connection is being closed 52 * @param {String} reason A human-readable string explaining why the connection is closing 53 * @param {WebSocket} target A reference to the target to which the event was dispatched 59 54 */ 60 55 constructor(code, reason, target) { … … 77 72 * Create a new `OpenEvent`. 78 73 * 79 * @param {WebSocket} target A reference to the target to which the event was 80 * dispatched 74 * @param {WebSocket} target A reference to the target to which the event was dispatched 81 75 */ 82 76 constructor(target) { … … 96 90 * 97 91 * @param {Object} error The error that generated this event 98 * @param {WebSocket} target A reference to the target to which the event was 99 * dispatched 92 * @param {WebSocket} target A reference to the target to which the event was dispatched 100 93 */ 101 94 constructor(error, target) { … … 117 110 * Register an event listener. 118 111 * 119 * @param {String} typeA string representing the event type to listen for112 * @param {String} method A string representing the event type to listen for 120 113 * @param {Function} listener The listener to add 121 * @param {Object} [options] An options object specifies characteristics about122 * the event listener123 * @param {Boolean} [options.once=false] A `Boolean`` indicating that the124 * listener should be invoked at most once after being added. If `true`,125 * the listener would be automatically removed when invoked.126 114 * @public 127 115 */ 128 addEventListener( type, listener, options) {116 addEventListener(method, listener) { 129 117 if (typeof listener !== 'function') return; 130 118 … … 145 133 } 146 134 147 const method = options && options.once ? 'once' : 'on'; 148 149 if (type === 'message') { 135 if (method === 'message') { 150 136 onMessage._listener = listener; 151 this [method](type, onMessage);152 } else if ( type=== 'close') {137 this.on(method, onMessage); 138 } else if (method === 'close') { 153 139 onClose._listener = listener; 154 this [method](type, onClose);155 } else if ( type=== 'error') {140 this.on(method, onClose); 141 } else if (method === 'error') { 156 142 onError._listener = listener; 157 this [method](type, onError);158 } else if ( type=== 'open') {143 this.on(method, onError); 144 } else if (method === 'open') { 159 145 onOpen._listener = listener; 160 this [method](type, onOpen);146 this.on(method, onOpen); 161 147 } else { 162 this [method](type, listener);148 this.on(method, listener); 163 149 } 164 150 }, … … 167 153 * Remove an event listener. 168 154 * 169 * @param {String} typeA string representing the event type to remove155 * @param {String} method A string representing the event type to remove 170 156 * @param {Function} listener The listener to remove 171 157 * @public 172 158 */ 173 removeEventListener( type, listener) {174 const listeners = this.listeners( type);159 removeEventListener(method, listener) { 160 const listeners = this.listeners(method); 175 161 176 for ( leti = 0; i < listeners.length; i++) {162 for (var i = 0; i < listeners.length; i++) { 177 163 if (listeners[i] === listener || listeners[i]._listener === listener) { 178 this.removeListener( type, listeners[i]);164 this.removeListener(method, listeners[i]); 179 165 } 180 166 }
Note:
See TracChangeset
for help on using the changeset viewer.