faye 1.4.0 → 1.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -87,320 +87,6 @@ var Faye =
87
87
  /************************************************************************/
88
88
  /******/ ({
89
89
 
90
- /***/ "./node_modules/asap/browser-asap.js":
91
- /*!*******************************************!*\
92
- !*** ./node_modules/asap/browser-asap.js ***!
93
- \*******************************************/
94
- /*! no static exports found */
95
- /***/ (function(module, exports, __webpack_require__) {
96
-
97
- "use strict";
98
-
99
-
100
- // rawAsap provides everything we need except exception management.
101
- var rawAsap = __webpack_require__(/*! ./raw */ "./node_modules/asap/browser-raw.js");
102
- // RawTasks are recycled to reduce GC churn.
103
- var freeTasks = [];
104
- // We queue errors to ensure they are thrown in right order (FIFO).
105
- // Array-as-queue is good enough here, since we are just dealing with exceptions.
106
- var pendingErrors = [];
107
- var requestErrorThrow = rawAsap.makeRequestCallFromTimer(throwFirstError);
108
-
109
- function throwFirstError() {
110
- if (pendingErrors.length) {
111
- throw pendingErrors.shift();
112
- }
113
- }
114
-
115
- /**
116
- * Calls a task as soon as possible after returning, in its own event, with priority
117
- * over other events like animation, reflow, and repaint. An error thrown from an
118
- * event will not interrupt, nor even substantially slow down the processing of
119
- * other events, but will be rather postponed to a lower priority event.
120
- * @param {{call}} task A callable object, typically a function that takes no
121
- * arguments.
122
- */
123
- module.exports = asap;
124
- function asap(task) {
125
- var rawTask;
126
- if (freeTasks.length) {
127
- rawTask = freeTasks.pop();
128
- } else {
129
- rawTask = new RawTask();
130
- }
131
- rawTask.task = task;
132
- rawAsap(rawTask);
133
- }
134
-
135
- // We wrap tasks with recyclable task objects. A task object implements
136
- // `call`, just like a function.
137
- function RawTask() {
138
- this.task = null;
139
- }
140
-
141
- // The sole purpose of wrapping the task is to catch the exception and recycle
142
- // the task object after its single use.
143
- RawTask.prototype.call = function () {
144
- try {
145
- this.task.call();
146
- } catch (error) {
147
- if (asap.onerror) {
148
- // This hook exists purely for testing purposes.
149
- // Its name will be periodically randomized to break any code that
150
- // depends on its existence.
151
- asap.onerror(error);
152
- } else {
153
- // In a web browser, exceptions are not fatal. However, to avoid
154
- // slowing down the queue of pending tasks, we rethrow the error in a
155
- // lower priority turn.
156
- pendingErrors.push(error);
157
- requestErrorThrow();
158
- }
159
- } finally {
160
- this.task = null;
161
- freeTasks[freeTasks.length] = this;
162
- }
163
- };
164
-
165
-
166
- /***/ }),
167
-
168
- /***/ "./node_modules/asap/browser-raw.js":
169
- /*!******************************************!*\
170
- !*** ./node_modules/asap/browser-raw.js ***!
171
- \******************************************/
172
- /*! no static exports found */
173
- /***/ (function(module, exports, __webpack_require__) {
174
-
175
- "use strict";
176
- /* WEBPACK VAR INJECTION */(function(global) {
177
-
178
- // Use the fastest means possible to execute a task in its own turn, with
179
- // priority over other events including IO, animation, reflow, and redraw
180
- // events in browsers.
181
- //
182
- // An exception thrown by a task will permanently interrupt the processing of
183
- // subsequent tasks. The higher level `asap` function ensures that if an
184
- // exception is thrown by a task, that the task queue will continue flushing as
185
- // soon as possible, but if you use `rawAsap` directly, you are responsible to
186
- // either ensure that no exceptions are thrown from your task, or to manually
187
- // call `rawAsap.requestFlush` if an exception is thrown.
188
- module.exports = rawAsap;
189
- function rawAsap(task) {
190
- if (!queue.length) {
191
- requestFlush();
192
- flushing = true;
193
- }
194
- // Equivalent to push, but avoids a function call.
195
- queue[queue.length] = task;
196
- }
197
-
198
- var queue = [];
199
- // Once a flush has been requested, no further calls to `requestFlush` are
200
- // necessary until the next `flush` completes.
201
- var flushing = false;
202
- // `requestFlush` is an implementation-specific method that attempts to kick
203
- // off a `flush` event as quickly as possible. `flush` will attempt to exhaust
204
- // the event queue before yielding to the browser's own event loop.
205
- var requestFlush;
206
- // The position of the next task to execute in the task queue. This is
207
- // preserved between calls to `flush` so that it can be resumed if
208
- // a task throws an exception.
209
- var index = 0;
210
- // If a task schedules additional tasks recursively, the task queue can grow
211
- // unbounded. To prevent memory exhaustion, the task queue will periodically
212
- // truncate already-completed tasks.
213
- var capacity = 1024;
214
-
215
- // The flush function processes all tasks that have been scheduled with
216
- // `rawAsap` unless and until one of those tasks throws an exception.
217
- // If a task throws an exception, `flush` ensures that its state will remain
218
- // consistent and will resume where it left off when called again.
219
- // However, `flush` does not make any arrangements to be called again if an
220
- // exception is thrown.
221
- function flush() {
222
- while (index < queue.length) {
223
- var currentIndex = index;
224
- // Advance the index before calling the task. This ensures that we will
225
- // begin flushing on the next task the task throws an error.
226
- index = index + 1;
227
- queue[currentIndex].call();
228
- // Prevent leaking memory for long chains of recursive calls to `asap`.
229
- // If we call `asap` within tasks scheduled by `asap`, the queue will
230
- // grow, but to avoid an O(n) walk for every task we execute, we don't
231
- // shift tasks off the queue after they have been executed.
232
- // Instead, we periodically shift 1024 tasks off the queue.
233
- if (index > capacity) {
234
- // Manually shift all values starting at the index back to the
235
- // beginning of the queue.
236
- for (var scan = 0, newLength = queue.length - index; scan < newLength; scan++) {
237
- queue[scan] = queue[scan + index];
238
- }
239
- queue.length -= index;
240
- index = 0;
241
- }
242
- }
243
- queue.length = 0;
244
- index = 0;
245
- flushing = false;
246
- }
247
-
248
- // `requestFlush` is implemented using a strategy based on data collected from
249
- // every available SauceLabs Selenium web driver worker at time of writing.
250
- // https://docs.google.com/spreadsheets/d/1mG-5UYGup5qxGdEMWkhP6BWCz053NUb2E1QoUTU16uA/edit#gid=783724593
251
-
252
- // Safari 6 and 6.1 for desktop, iPad, and iPhone are the only browsers that
253
- // have WebKitMutationObserver but not un-prefixed MutationObserver.
254
- // Must use `global` or `self` instead of `window` to work in both frames and web
255
- // workers. `global` is a provision of Browserify, Mr, Mrs, or Mop.
256
-
257
- /* globals self */
258
- var scope = typeof global !== "undefined" ? global : self;
259
- var BrowserMutationObserver = scope.MutationObserver || scope.WebKitMutationObserver;
260
-
261
- // MutationObservers are desirable because they have high priority and work
262
- // reliably everywhere they are implemented.
263
- // They are implemented in all modern browsers.
264
- //
265
- // - Android 4-4.3
266
- // - Chrome 26-34
267
- // - Firefox 14-29
268
- // - Internet Explorer 11
269
- // - iPad Safari 6-7.1
270
- // - iPhone Safari 7-7.1
271
- // - Safari 6-7
272
- if (typeof BrowserMutationObserver === "function") {
273
- requestFlush = makeRequestCallFromMutationObserver(flush);
274
-
275
- // MessageChannels are desirable because they give direct access to the HTML
276
- // task queue, are implemented in Internet Explorer 10, Safari 5.0-1, and Opera
277
- // 11-12, and in web workers in many engines.
278
- // Although message channels yield to any queued rendering and IO tasks, they
279
- // would be better than imposing the 4ms delay of timers.
280
- // However, they do not work reliably in Internet Explorer or Safari.
281
-
282
- // Internet Explorer 10 is the only browser that has setImmediate but does
283
- // not have MutationObservers.
284
- // Although setImmediate yields to the browser's renderer, it would be
285
- // preferrable to falling back to setTimeout since it does not have
286
- // the minimum 4ms penalty.
287
- // Unfortunately there appears to be a bug in Internet Explorer 10 Mobile (and
288
- // Desktop to a lesser extent) that renders both setImmediate and
289
- // MessageChannel useless for the purposes of ASAP.
290
- // https://github.com/kriskowal/q/issues/396
291
-
292
- // Timers are implemented universally.
293
- // We fall back to timers in workers in most engines, and in foreground
294
- // contexts in the following browsers.
295
- // However, note that even this simple case requires nuances to operate in a
296
- // broad spectrum of browsers.
297
- //
298
- // - Firefox 3-13
299
- // - Internet Explorer 6-9
300
- // - iPad Safari 4.3
301
- // - Lynx 2.8.7
302
- } else {
303
- requestFlush = makeRequestCallFromTimer(flush);
304
- }
305
-
306
- // `requestFlush` requests that the high priority event queue be flushed as
307
- // soon as possible.
308
- // This is useful to prevent an error thrown in a task from stalling the event
309
- // queue if the exception handled by Node.js’s
310
- // `process.on("uncaughtException")` or by a domain.
311
- rawAsap.requestFlush = requestFlush;
312
-
313
- // To request a high priority event, we induce a mutation observer by toggling
314
- // the text of a text node between "1" and "-1".
315
- function makeRequestCallFromMutationObserver(callback) {
316
- var toggle = 1;
317
- var observer = new BrowserMutationObserver(callback);
318
- var node = document.createTextNode("");
319
- observer.observe(node, {characterData: true});
320
- return function requestCall() {
321
- toggle = -toggle;
322
- node.data = toggle;
323
- };
324
- }
325
-
326
- // The message channel technique was discovered by Malte Ubl and was the
327
- // original foundation for this library.
328
- // http://www.nonblocking.io/2011/06/windownexttick.html
329
-
330
- // Safari 6.0.5 (at least) intermittently fails to create message ports on a
331
- // page's first load. Thankfully, this version of Safari supports
332
- // MutationObservers, so we don't need to fall back in that case.
333
-
334
- // function makeRequestCallFromMessageChannel(callback) {
335
- // var channel = new MessageChannel();
336
- // channel.port1.onmessage = callback;
337
- // return function requestCall() {
338
- // channel.port2.postMessage(0);
339
- // };
340
- // }
341
-
342
- // For reasons explained above, we are also unable to use `setImmediate`
343
- // under any circumstances.
344
- // Even if we were, there is another bug in Internet Explorer 10.
345
- // It is not sufficient to assign `setImmediate` to `requestFlush` because
346
- // `setImmediate` must be called *by name* and therefore must be wrapped in a
347
- // closure.
348
- // Never forget.
349
-
350
- // function makeRequestCallFromSetImmediate(callback) {
351
- // return function requestCall() {
352
- // setImmediate(callback);
353
- // };
354
- // }
355
-
356
- // Safari 6.0 has a problem where timers will get lost while the user is
357
- // scrolling. This problem does not impact ASAP because Safari 6.0 supports
358
- // mutation observers, so that implementation is used instead.
359
- // However, if we ever elect to use timers in Safari, the prevalent work-around
360
- // is to add a scroll event listener that calls for a flush.
361
-
362
- // `setTimeout` does not call the passed callback if the delay is less than
363
- // approximately 7 in web workers in Firefox 8 through 18, and sometimes not
364
- // even then.
365
-
366
- function makeRequestCallFromTimer(callback) {
367
- return function requestCall() {
368
- // We dispatch a timeout with a specified delay of 0 for engines that
369
- // can reliably accommodate that request. This will usually be snapped
370
- // to a 4 milisecond delay, but once we're flushing, there's no delay
371
- // between events.
372
- var timeoutHandle = setTimeout(handleTimer, 0);
373
- // However, since this timer gets frequently dropped in Firefox
374
- // workers, we enlist an interval handle that will try to fire
375
- // an event 20 times per second until it succeeds.
376
- var intervalHandle = setInterval(handleTimer, 50);
377
-
378
- function handleTimer() {
379
- // Whichever timer succeeds will cancel both timers and
380
- // execute the callback.
381
- clearTimeout(timeoutHandle);
382
- clearInterval(intervalHandle);
383
- callback();
384
- }
385
- };
386
- }
387
-
388
- // This is for `asap.js` only.
389
- // Its name will be periodically randomized to break any code that depends on
390
- // its existence.
391
- rawAsap.makeRequestCallFromTimer = makeRequestCallFromTimer;
392
-
393
- // ASAP was originally a nextTick shim included in Q. This was factored out
394
- // into this ASAP package. It was later adapted to RSVP which made further
395
- // amendments. These decisions, particularly to marginalize MessageChannel and
396
- // to capture the MutationObserver implementation in a closure, were integrated
397
- // back into ASAP proper.
398
- // https://github.com/tildeio/rsvp.js/blob/cddf7232546a9cf858524b75cde6f9edf72620a7/lib/rsvp/asap.js
399
-
400
- /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../webpack/buildin/global.js */ "./node_modules/webpack/buildin/global.js")))
401
-
402
- /***/ }),
403
-
404
90
  /***/ "./node_modules/webpack/buildin/global.js":
405
91
  /*!***********************************!*\
406
92
  !*** (webpack)/buildin/global.js ***!
@@ -469,28 +155,31 @@ module.exports = Faye;
469
155
  "use strict";
470
156
  /* WEBPACK VAR INJECTION */(function(global) {
471
157
 
472
- var Promise = __webpack_require__(/*! ../util/promise */ "./src/util/promise.js");
473
-
474
158
  module.exports = {
475
159
  then: function(callback, errback) {
476
160
  var self = this;
477
- if (!this._promise)
161
+
162
+ if (!this._promise) {
478
163
  this._promise = new Promise(function(resolve, reject) {
479
164
  self._resolve = resolve;
480
165
  self._reject = reject;
481
166
  });
167
+ }
482
168
 
483
- if (arguments.length === 0)
169
+ if (arguments.length === 0) {
484
170
  return this._promise;
485
- else
171
+ } else {
486
172
  return this._promise.then(callback, errback);
173
+ }
487
174
  },
488
175
 
489
176
  callback: function(callback, context) {
177
+ if (!callback) return;
490
178
  return this.then(function(value) { callback.call(context, value) });
491
179
  },
492
180
 
493
181
  errback: function(callback, context) {
182
+ if (!callback) return;
494
183
  return this.then(null, function(reason) { callback.call(context, reason) });
495
184
  },
496
185
 
@@ -507,12 +196,13 @@ module.exports = {
507
196
 
508
197
  this.then();
509
198
 
510
- if (status === 'succeeded')
199
+ if (status === 'succeeded') {
511
200
  this._resolve(value);
512
- else if (status === 'failed')
201
+ } else if (status === 'failed') {
513
202
  this._reject(value);
514
- else
203
+ } else {
515
204
  delete this._promise;
205
+ }
516
206
  }
517
207
  };
518
208
 
@@ -560,19 +250,19 @@ var Logging = {
560
250
  if (klass) banner += '.' + klass;
561
251
  banner += '] ';
562
252
 
563
- if (typeof logger[level] === 'function')
253
+ if (typeof logger[level] === 'function') {
564
254
  logger[level](banner + message);
565
- else if (typeof logger === 'function')
255
+ } else if (typeof logger === 'function') {
566
256
  logger(banner + message);
257
+ }
567
258
  }
568
259
  };
569
260
 
570
- for (var key in Logging.LOG_LEVELS)
571
- (function(level) {
572
- Logging[level] = function() {
573
- this.writeLog(arguments, level);
574
- };
575
- })(key);
261
+ for (let level of Object.keys(Logging.LOG_LEVELS)) {
262
+ Logging[level] = function() {
263
+ this.writeLog(arguments, level);
264
+ };
265
+ }
576
266
 
577
267
  module.exports = Logging;
578
268
 
@@ -589,8 +279,7 @@ module.exports = Logging;
589
279
  "use strict";
590
280
 
591
281
 
592
- var assign = __webpack_require__(/*! ../util/assign */ "./src/util/assign.js"),
593
- EventEmitter = __webpack_require__(/*! ../util/event_emitter */ "./src/util/event_emitter.js");
282
+ var EventEmitter = __webpack_require__(/*! ../util/event_emitter */ "./src/util/event_emitter.js");
594
283
 
595
284
  var Publisher = {
596
285
  countListeners: function(eventType) {
@@ -620,7 +309,7 @@ var Publisher = {
620
309
  }
621
310
  };
622
311
 
623
- assign(Publisher, EventEmitter.prototype);
312
+ Object.assign(Publisher, EventEmitter.prototype);
624
313
  Publisher.trigger = Publisher.emit;
625
314
 
626
315
  module.exports = Publisher;
@@ -640,26 +329,26 @@ module.exports = Publisher;
640
329
 
641
330
  module.exports = {
642
331
  addTimeout: function(name, delay, callback, context) {
643
- this._timeouts = this._timeouts || {};
644
- if (this._timeouts.hasOwnProperty(name)) return;
332
+ this._timeouts = this._timeouts || new Map();
333
+ if (this._timeouts.has(name)) return;
645
334
  var self = this;
646
- this._timeouts[name] = global.setTimeout(function() {
335
+ this._timeouts.set(name, global.setTimeout(function() {
647
336
  delete self._timeouts[name];
648
337
  callback.call(context);
649
- }, 1000 * delay);
338
+ }, 1000 * delay));
650
339
  },
651
340
 
652
341
  removeTimeout: function(name) {
653
- this._timeouts = this._timeouts || {};
654
- var timeout = this._timeouts[name];
342
+ this._timeouts = this._timeouts || new Map();
343
+ var timeout = this._timeouts.get(name);
655
344
  if (!timeout) return;
656
345
  global.clearTimeout(timeout);
657
- delete this._timeouts[name];
346
+ this._timeouts.delete(name);
658
347
  },
659
348
 
660
349
  removeAllTimeouts: function() {
661
- this._timeouts = this._timeouts || {};
662
- for (var name in this._timeouts) this.removeTimeout(name);
350
+ this._timeouts = this._timeouts || new Map();
351
+ for (let name of this._timeouts.keys()) this.removeTimeout(name);
663
352
  }
664
353
  };
665
354
 
@@ -678,7 +367,6 @@ module.exports = {
678
367
 
679
368
 
680
369
  var Class = __webpack_require__(/*! ../util/class */ "./src/util/class.js"),
681
- assign = __webpack_require__(/*! ../util/assign */ "./src/util/assign.js"),
682
370
  Publisher = __webpack_require__(/*! ../mixins/publisher */ "./src/mixins/publisher.js"),
683
371
  Grammar = __webpack_require__(/*! ./grammar */ "./src/protocol/grammar.js");
684
372
 
@@ -696,9 +384,9 @@ var Channel = Class({
696
384
  }
697
385
  });
698
386
 
699
- assign(Channel.prototype, Publisher);
387
+ Object.assign(Channel.prototype, Publisher);
700
388
 
701
- assign(Channel, {
389
+ Object.assign(Channel, {
702
390
  HANDSHAKE: '/meta/handshake',
703
391
  CONNECT: '/meta/connect',
704
392
  SUBSCRIBE: '/meta/subscribe',
@@ -756,17 +444,15 @@ assign(Channel, {
756
444
 
757
445
  Set: Class({
758
446
  initialize: function() {
759
- this._channels = {};
447
+ this._channels = new Map();
760
448
  },
761
449
 
762
450
  getKeys: function() {
763
- var keys = [];
764
- for (var key in this._channels) keys.push(key);
765
- return keys;
451
+ return [...this._channels.keys()];
766
452
  },
767
453
 
768
454
  remove: function(name) {
769
- delete this._channels[name];
455
+ this._channels.delete(name);
770
456
  },
771
457
 
772
458
  hasSubscription: function(name) {
@@ -774,16 +460,14 @@ assign(Channel, {
774
460
  },
775
461
 
776
462
  subscribe: function(names, subscription) {
777
- var name;
778
- for (var i = 0, n = names.length; i < n; i++) {
779
- name = names[i];
780
- var channel = this._channels[name] = this._channels[name] || new Channel(name);
781
- channel.bind('message', subscription);
463
+ for (let name of names) {
464
+ if (!this._channels.has(name)) this._channels.set(name, new Channel(name));
465
+ this._channels.get(name).bind('message', subscription);
782
466
  }
783
467
  },
784
468
 
785
469
  unsubscribe: function(name, subscription) {
786
- var channel = this._channels[name];
470
+ var channel = this._channels.get(name);
787
471
  if (!channel) return false;
788
472
  channel.unbind('message', subscription);
789
473
 
@@ -798,8 +482,8 @@ assign(Channel, {
798
482
  distributeMessage: function(message) {
799
483
  var channels = Channel.expand(message.channel);
800
484
 
801
- for (var i = 0, n = channels.length; i < n; i++) {
802
- var channel = this._channels[channels[i]];
485
+ for (let chan of channels) {
486
+ var channel = this._channels.get(chan);
803
487
  if (channel) channel.trigger('message', message);
804
488
  }
805
489
  }
@@ -821,13 +505,10 @@ module.exports = Channel;
821
505
  "use strict";
822
506
  /* WEBPACK VAR INJECTION */(function(global) {
823
507
 
824
- var asap = __webpack_require__(/*! asap */ "./node_modules/asap/browser-asap.js"),
825
- Class = __webpack_require__(/*! ../util/class */ "./src/util/class.js"),
826
- Promise = __webpack_require__(/*! ../util/promise */ "./src/util/promise.js"),
508
+ var Class = __webpack_require__(/*! ../util/class */ "./src/util/class.js"),
827
509
  array = __webpack_require__(/*! ../util/array */ "./src/util/array.js"),
828
510
  browser = __webpack_require__(/*! ../util/browser */ "./src/util/browser/event.js"),
829
511
  constants = __webpack_require__(/*! ../util/constants */ "./src/util/constants.js"),
830
- assign = __webpack_require__(/*! ../util/assign */ "./src/util/assign.js"),
831
512
  validateOptions = __webpack_require__(/*! ../util/validate_options */ "./src/util/validate_options.js"),
832
513
  Deferrable = __webpack_require__(/*! ../mixins/deferrable */ "./src/mixins/deferrable.js"),
833
514
  Logging = __webpack_require__(/*! ../mixins/logging */ "./src/mixins/logging.js"),
@@ -866,7 +547,7 @@ var Client = Class({ className: 'Client',
866
547
  this._messageId = 0;
867
548
  this._state = this.UNCONNECTED;
868
549
 
869
- this._responseCallbacks = {};
550
+ this._responseCallbacks = new Map();
870
551
 
871
552
  this._advice = {
872
553
  reconnect: this.RETRY,
@@ -877,11 +558,13 @@ var Client = Class({ className: 'Client',
877
558
 
878
559
  this._dispatcher.bind('message', this._receiveMessage, this);
879
560
 
880
- if (browser.Event && global.onbeforeunload !== undefined)
561
+ if (browser.Event && global.onbeforeunload !== undefined) {
881
562
  browser.Event.on(global, 'beforeunload', function() {
882
- if (array.indexOf(this._dispatcher._disabled, 'autodisconnect') < 0)
563
+ if (array.indexOf(this._dispatcher._disabled, 'autodisconnect') < 0) {
883
564
  this.disconnect();
565
+ }
884
566
  }, this);
567
+ }
885
568
  },
886
569
 
887
570
  addWebsocketExtension: function(extension) {
@@ -941,7 +624,7 @@ var Client = Class({ className: 'Client',
941
624
  this.info('Handshake successful: ?', this._dispatcher.clientId);
942
625
 
943
626
  this.subscribe(this._channels.getKeys(), true);
944
- if (callback) asap(function() { callback.call(context) });
627
+ if (callback) Promise.resolve().then(function() { callback.call(context) });
945
628
 
946
629
  } else {
947
630
  this.info('Handshake unsuccessful');
@@ -964,8 +647,9 @@ var Client = Class({ className: 'Client',
964
647
  if (this._advice.reconnect === this.NONE) return;
965
648
  if (this._state === this.DISCONNECTED) return;
966
649
 
967
- if (this._state === this.UNCONNECTED)
650
+ if (this._state === this.UNCONNECTED) {
968
651
  return this.handshake(function() { this.connect(callback, context) }, this);
652
+ }
969
653
 
970
654
  this.callback(callback, context);
971
655
  if (this._state !== this.CONNECTED) return;
@@ -1031,10 +715,11 @@ var Client = Class({ className: 'Client',
1031
715
  // * id
1032
716
  // * timestamp
1033
717
  subscribe: function(channel, callback, context) {
1034
- if (channel instanceof Array)
718
+ if (channel instanceof Array) {
1035
719
  return array.map(channel, function(c) {
1036
720
  return this.subscribe(c, callback, context);
1037
721
  }, this);
722
+ }
1038
723
 
1039
724
  var subscription = new Subscription(this, channel, callback, context),
1040
725
  force = (callback === true),
@@ -1081,10 +766,11 @@ var Client = Class({ className: 'Client',
1081
766
  // * id
1082
767
  // * timestamp
1083
768
  unsubscribe: function(channel, subscription) {
1084
- if (channel instanceof Array)
769
+ if (channel instanceof Array) {
1085
770
  return array.map(channel, function(c) {
1086
771
  return this.unsubscribe(c, subscription);
1087
772
  }, this);
773
+ }
1088
774
 
1089
775
  var dead = this._channels.unsubscribe(channel, subscription);
1090
776
  if (!dead) return;
@@ -1125,10 +811,11 @@ var Client = Class({ className: 'Client',
1125
811
  clientId: this._dispatcher.clientId
1126
812
 
1127
813
  }, options, function(response) {
1128
- if (response.successful)
814
+ if (response.successful) {
1129
815
  publication.setDeferredStatus('succeeded');
1130
- else
816
+ } else {
1131
817
  publication.setDeferredStatus('failed', Error.parse(response.error));
818
+ }
1132
819
  }, this);
1133
820
  }, this);
1134
821
 
@@ -1144,7 +831,7 @@ var Client = Class({ className: 'Client',
1144
831
 
1145
832
  this.pipeThroughExtensions('outgoing', message, null, function(message) {
1146
833
  if (!message) return;
1147
- if (callback) this._responseCallbacks[message.id] = [callback, context];
834
+ if (callback) this._responseCallbacks.set(message.id, [callback, context]);
1148
835
  this._dispatcher.sendMessage(message, timeout, options || {});
1149
836
  }, this);
1150
837
  },
@@ -1159,8 +846,8 @@ var Client = Class({ className: 'Client',
1159
846
  var id = message.id, callback;
1160
847
 
1161
848
  if (message.successful !== undefined) {
1162
- callback = this._responseCallbacks[id];
1163
- delete this._responseCallbacks[id];
849
+ callback = this._responseCallbacks.get(id);
850
+ this._responseCallbacks.delete(id);
1164
851
  }
1165
852
 
1166
853
  this.pipeThroughExtensions('incoming', message, null, function(message) {
@@ -1172,7 +859,7 @@ var Client = Class({ className: 'Client',
1172
859
  },
1173
860
 
1174
861
  _handleAdvice: function(advice) {
1175
- assign(this._advice, advice);
862
+ Object.assign(this._advice, advice);
1176
863
  this._dispatcher.timeout = this._advice.timeout / 1000;
1177
864
 
1178
865
  if (this._advice.reconnect === this.HANDSHAKE && this._state !== this.DISCONNECTED) {
@@ -1198,10 +885,10 @@ var Client = Class({ className: 'Client',
1198
885
  }
1199
886
  });
1200
887
 
1201
- assign(Client.prototype, Deferrable);
1202
- assign(Client.prototype, Publisher);
1203
- assign(Client.prototype, Logging);
1204
- assign(Client.prototype, Extensible);
888
+ Object.assign(Client.prototype, Deferrable);
889
+ Object.assign(Client.prototype, Publisher);
890
+ Object.assign(Client.prototype, Logging);
891
+ Object.assign(Client.prototype, Extensible);
1205
892
 
1206
893
  module.exports = Client;
1207
894
 
@@ -1222,7 +909,6 @@ module.exports = Client;
1222
909
  var Class = __webpack_require__(/*! ../util/class */ "./src/util/class.js"),
1223
910
  URI = __webpack_require__(/*! ../util/uri */ "./src/util/uri.js"),
1224
911
  cookies = __webpack_require__(/*! ../util/cookies */ "./src/util/cookies/browser_cookies.js"),
1225
- assign = __webpack_require__(/*! ../util/assign */ "./src/util/assign.js"),
1226
912
  Logging = __webpack_require__(/*! ../mixins/logging */ "./src/mixins/logging.js"),
1227
913
  Publisher = __webpack_require__(/*! ../mixins/publisher */ "./src/mixins/publisher.js"),
1228
914
  Transport = __webpack_require__(/*! ../transport */ "./src/transport/browser_transports.js"),
@@ -1242,7 +928,7 @@ var Dispatcher = Class({ className: 'Dispatcher',
1242
928
 
1243
929
  this.cookies = cookies.CookieJar && new cookies.CookieJar();
1244
930
  this._disabled = [];
1245
- this._envelopes = {};
931
+ this._envelopes = new Map();
1246
932
  this.headers = {};
1247
933
  this.retry = options.retry || this.DEFAULT_RETRY;
1248
934
  this._scheduler = options.scheduler || Scheduler;
@@ -1256,15 +942,15 @@ var Dispatcher = Class({ className: 'Dispatcher',
1256
942
  var exts = options.websocketExtensions;
1257
943
  if (exts) {
1258
944
  exts = [].concat(exts);
1259
- for (var i = 0, n = exts.length; i < n; i++)
1260
- this.addWebsocketExtension(exts[i]);
945
+ for (let ext of exts) this.addWebsocketExtension(ext);
1261
946
  }
1262
947
 
1263
948
  this.tls = options.tls || {};
1264
949
  this.tls.ca = this.tls.ca || options.ca;
1265
950
 
1266
- for (var type in this._alternates)
1267
- this._alternates[type] = URI.parse(this._alternates[type]);
951
+ for (let [type, alt] of Object.entries(this._alternates)) {
952
+ this._alternates[type] = URI.parse(alt);
953
+ }
1268
954
 
1269
955
  this.maxRequestSize = this.MAX_REQUEST_SIZE;
1270
956
  },
@@ -1314,12 +1000,13 @@ var Dispatcher = Class({ className: 'Dispatcher',
1314
1000
  var id = message.id,
1315
1001
  attempts = options.attempts,
1316
1002
  deadline = options.deadline && new Date().getTime() + (options.deadline * 1000),
1317
- envelope = this._envelopes[id],
1003
+ envelope = this._envelopes.get(id),
1318
1004
  scheduler;
1319
1005
 
1320
1006
  if (!envelope) {
1321
1007
  scheduler = new this._scheduler(message, { timeout: timeout, interval: this.retry, attempts: attempts, deadline: deadline });
1322
- envelope = this._envelopes[id] = { message: message, scheduler: scheduler };
1008
+ envelope = { message: message, scheduler: scheduler };
1009
+ this._envelopes.set(id, envelope);
1323
1010
  }
1324
1011
 
1325
1012
  this._sendEnvelope(envelope);
@@ -1335,7 +1022,7 @@ var Dispatcher = Class({ className: 'Dispatcher',
1335
1022
 
1336
1023
  if (!scheduler.isDeliverable()) {
1337
1024
  scheduler.abort();
1338
- delete this._envelopes[message.id];
1025
+ this._envelopes.delete(message.id);
1339
1026
  return;
1340
1027
  }
1341
1028
 
@@ -1348,11 +1035,11 @@ var Dispatcher = Class({ className: 'Dispatcher',
1348
1035
  },
1349
1036
 
1350
1037
  handleResponse: function(reply) {
1351
- var envelope = this._envelopes[reply.id];
1038
+ var envelope = this._envelopes.get(reply.id);
1352
1039
 
1353
1040
  if (reply.successful !== undefined && envelope) {
1354
1041
  envelope.scheduler.succeed();
1355
- delete this._envelopes[reply.id];
1042
+ this._envelopes.delete(reply.id);
1356
1043
  global.clearTimeout(envelope.timer);
1357
1044
  }
1358
1045
 
@@ -1364,7 +1051,7 @@ var Dispatcher = Class({ className: 'Dispatcher',
1364
1051
  },
1365
1052
 
1366
1053
  handleError: function(message, immediate) {
1367
- var envelope = this._envelopes[message.id],
1054
+ var envelope = this._envelopes.get(message.id),
1368
1055
  request = envelope && envelope.request,
1369
1056
  self = this;
1370
1057
 
@@ -1399,8 +1086,8 @@ Dispatcher.create = function(client, endpoint, options) {
1399
1086
  return new Dispatcher(client, endpoint, options);
1400
1087
  };
1401
1088
 
1402
- assign(Dispatcher.prototype, Publisher);
1403
- assign(Dispatcher.prototype, Logging);
1089
+ Object.assign(Dispatcher.prototype, Publisher);
1090
+ Object.assign(Dispatcher.prototype, Logging);
1404
1091
 
1405
1092
  module.exports = Dispatcher;
1406
1093
 
@@ -1463,12 +1150,11 @@ var errors = {
1463
1150
  serverError: [500, 'Internal server error']
1464
1151
  };
1465
1152
 
1466
- for (var name in errors)
1467
- (function(name) {
1468
- Error[name] = function() {
1469
- return new Error(errors[name][0], arguments, errors[name][1]).toString();
1470
- };
1471
- })(name);
1153
+ for (let [name, [status, msg]] of Object.entries(errors)) {
1154
+ Error[name] = function() {
1155
+ return new Error(status, arguments, msg).toString();
1156
+ };
1157
+ }
1472
1158
 
1473
1159
  module.exports = Error;
1474
1160
 
@@ -1485,8 +1171,7 @@ module.exports = Error;
1485
1171
  "use strict";
1486
1172
 
1487
1173
 
1488
- var assign = __webpack_require__(/*! ../util/assign */ "./src/util/assign.js"),
1489
- Logging = __webpack_require__(/*! ../mixins/logging */ "./src/mixins/logging.js");
1174
+ var Logging = __webpack_require__(/*! ../mixins/logging */ "./src/mixins/logging.js");
1490
1175
 
1491
1176
  var Extensible = {
1492
1177
  addExtension: function(extension) {
@@ -1527,7 +1212,7 @@ var Extensible = {
1527
1212
  }
1528
1213
  };
1529
1214
 
1530
- assign(Extensible, Logging);
1215
+ Object.assign(Extensible, Logging);
1531
1216
 
1532
1217
  module.exports = Extensible;
1533
1218
 
@@ -1582,15 +1267,13 @@ module.exports = Class(Deferrable);
1582
1267
  "use strict";
1583
1268
 
1584
1269
 
1585
- var assign = __webpack_require__(/*! ../util/assign */ "./src/util/assign.js");
1586
-
1587
1270
  var Scheduler = function(message, options) {
1588
1271
  this.message = message;
1589
1272
  this.options = options;
1590
1273
  this.attempts = 0;
1591
1274
  };
1592
1275
 
1593
- assign(Scheduler.prototype, {
1276
+ Object.assign(Scheduler.prototype, {
1594
1277
  getTimeout: function() {
1595
1278
  return this.options.timeout;
1596
1279
  },
@@ -1605,11 +1288,12 @@ assign(Scheduler.prototype, {
1605
1288
  deadline = this.options.deadline,
1606
1289
  now = new Date().getTime();
1607
1290
 
1608
- if (attempts !== undefined && made >= attempts)
1291
+ if (attempts !== undefined && made >= attempts) {
1609
1292
  return false;
1610
-
1611
- if (deadline !== undefined && now > deadline)
1293
+ }
1294
+ if (deadline !== undefined && now > deadline) {
1612
1295
  return false;
1296
+ }
1613
1297
 
1614
1298
  return true;
1615
1299
  },
@@ -1641,7 +1325,6 @@ module.exports = Scheduler;
1641
1325
 
1642
1326
 
1643
1327
  var Class = __webpack_require__(/*! ../util/class */ "./src/util/class.js"),
1644
- assign = __webpack_require__(/*! ../util/assign */ "./src/util/assign.js"),
1645
1328
  Deferrable = __webpack_require__(/*! ../mixins/deferrable */ "./src/mixins/deferrable.js");
1646
1329
 
1647
1330
  var Subscription = Class({
@@ -1661,11 +1344,12 @@ var Subscription = Class({
1661
1344
  apply: function(context, args) {
1662
1345
  var message = args[0];
1663
1346
 
1664
- if (this._callback)
1347
+ if (this._callback) {
1665
1348
  this._callback.call(this._context, message.data);
1666
-
1667
- if (this._withChannel)
1349
+ }
1350
+ if (this._withChannel) {
1668
1351
  this._withChannel[0].call(this._withChannel[1], message.channel, message.data);
1352
+ }
1669
1353
  },
1670
1354
 
1671
1355
  cancel: function() {
@@ -1679,7 +1363,7 @@ var Subscription = Class({
1679
1363
  }
1680
1364
  });
1681
1365
 
1682
- assign(Subscription.prototype, Deferrable);
1366
+ Object.assign(Subscription.prototype, Deferrable);
1683
1367
 
1684
1368
  module.exports = Subscription;
1685
1369
 
@@ -1722,11 +1406,10 @@ module.exports = Transport;
1722
1406
  var Class = __webpack_require__(/*! ../util/class */ "./src/util/class.js"),
1723
1407
  Set = __webpack_require__(/*! ../util/set */ "./src/util/set.js"),
1724
1408
  URI = __webpack_require__(/*! ../util/uri */ "./src/util/uri.js"),
1725
- assign = __webpack_require__(/*! ../util/assign */ "./src/util/assign.js"),
1726
1409
  toJSON = __webpack_require__(/*! ../util/to_json */ "./src/util/to_json.js"),
1727
1410
  Transport = __webpack_require__(/*! ./transport */ "./src/transport/transport.js");
1728
1411
 
1729
- var CORS = assign(Class(Transport, {
1412
+ var CORS = Object.assign(Class(Transport, {
1730
1413
  encode: function(messages) {
1731
1414
  return 'message=' + encodeURIComponent(toJSON(messages));
1732
1415
  },
@@ -1736,17 +1419,15 @@ var CORS = assign(Class(Transport, {
1736
1419
  xhr = new xhrClass(),
1737
1420
  id = ++CORS._id,
1738
1421
  headers = this._dispatcher.headers,
1739
- self = this,
1740
- key;
1422
+ self = this;
1741
1423
 
1742
1424
  xhr.open('POST', this.endpoint.href, true);
1743
1425
  xhr.withCredentials = true;
1744
1426
 
1745
1427
  if (xhr.setRequestHeader) {
1746
1428
  xhr.setRequestHeader('Pragma', 'no-cache');
1747
- for (key in headers) {
1748
- if (!headers.hasOwnProperty(key)) continue;
1749
- xhr.setRequestHeader(key, headers[key]);
1429
+ for (let [key, value] of Object.entries(headers)) {
1430
+ xhr.setRequestHeader(key, value);
1750
1431
  }
1751
1432
  }
1752
1433
 
@@ -1763,10 +1444,11 @@ var CORS = assign(Class(Transport, {
1763
1444
 
1764
1445
  cleanUp();
1765
1446
 
1766
- if (replies)
1447
+ if (replies) {
1767
1448
  self._receive(replies);
1768
- else
1449
+ } else {
1769
1450
  self._handleError(messages);
1451
+ }
1770
1452
  };
1771
1453
 
1772
1454
  xhr.onerror = xhr.ontimeout = function() {
@@ -1776,8 +1458,9 @@ var CORS = assign(Class(Transport, {
1776
1458
 
1777
1459
  xhr.onprogress = function() {};
1778
1460
 
1779
- if (xhrClass === global.XDomainRequest)
1461
+ if (xhrClass === global.XDomainRequest) {
1780
1462
  CORS._pending.add({ id: id, xhr: xhr });
1463
+ }
1781
1464
 
1782
1465
  xhr.send(this.encode(messages));
1783
1466
  return xhr;
@@ -1787,12 +1470,12 @@ var CORS = assign(Class(Transport, {
1787
1470
  _pending: new Set(),
1788
1471
 
1789
1472
  isUsable: function(dispatcher, endpoint, callback, context) {
1790
- if (URI.isSameOrigin(endpoint))
1473
+ if (URI.isSameOrigin(endpoint)) {
1791
1474
  return callback.call(context, false);
1792
-
1793
- if (global.XDomainRequest)
1475
+ }
1476
+ if (global.XDomainRequest) {
1794
1477
  return callback.call(context, endpoint.protocol === location.protocol);
1795
-
1478
+ }
1796
1479
  if (global.XMLHttpRequest) {
1797
1480
  var xhr = new XMLHttpRequest();
1798
1481
  return callback.call(context, xhr.withCredentials !== undefined);
@@ -1819,20 +1502,18 @@ module.exports = CORS;
1819
1502
 
1820
1503
  var Class = __webpack_require__(/*! ../util/class */ "./src/util/class.js"),
1821
1504
  URI = __webpack_require__(/*! ../util/uri */ "./src/util/uri.js"),
1822
- copyObject = __webpack_require__(/*! ../util/copy_object */ "./src/util/copy_object.js"),
1823
- assign = __webpack_require__(/*! ../util/assign */ "./src/util/assign.js"),
1824
1505
  Deferrable = __webpack_require__(/*! ../mixins/deferrable */ "./src/mixins/deferrable.js"),
1825
1506
  Transport = __webpack_require__(/*! ./transport */ "./src/transport/transport.js"),
1826
1507
  XHR = __webpack_require__(/*! ./xhr */ "./src/transport/xhr.js");
1827
1508
 
1828
- var EventSource = assign(Class(Transport, {
1509
+ var EventSource = Object.assign(Class(Transport, {
1829
1510
  initialize: function(dispatcher, endpoint) {
1830
1511
  Transport.prototype.initialize.call(this, dispatcher, endpoint);
1831
1512
  if (!global.EventSource) return this.setDeferredStatus('failed');
1832
1513
 
1833
1514
  this._xhr = new XHR(dispatcher, endpoint);
1834
1515
 
1835
- endpoint = copyObject(endpoint);
1516
+ endpoint = URI.clone(endpoint);
1836
1517
  endpoint.pathname += '/' + dispatcher.clientId;
1837
1518
 
1838
1519
  var socket = new global.EventSource(URI.stringify(endpoint)),
@@ -1856,10 +1537,11 @@ var EventSource = assign(Class(Transport, {
1856
1537
  var replies;
1857
1538
  try { replies = JSON.parse(event.data) } catch (error) {}
1858
1539
 
1859
- if (replies)
1540
+ if (replies) {
1860
1541
  self._receive(replies);
1861
- else
1542
+ } else {
1862
1543
  self._handleError([]);
1544
+ }
1863
1545
  };
1864
1546
 
1865
1547
  this._socket = socket;
@@ -1897,19 +1579,20 @@ var EventSource = assign(Class(Transport, {
1897
1579
  },
1898
1580
 
1899
1581
  create: function(dispatcher, endpoint) {
1900
- var sockets = dispatcher.transports.eventsource = dispatcher.transports.eventsource || {},
1901
- id = dispatcher.clientId;
1582
+ var transports = dispatcher.transports,
1583
+ sockets = transports.eventsource = transports.eventsource || new Map(),
1584
+ id = dispatcher.clientId;
1902
1585
 
1903
- var url = copyObject(endpoint);
1586
+ var url = URI.clone(endpoint);
1904
1587
  url.pathname += '/' + (id || '');
1905
1588
  url = URI.stringify(url);
1906
1589
 
1907
- sockets[url] = sockets[url] || new this(dispatcher, endpoint);
1908
- return sockets[url];
1590
+ if (!sockets.has(url)) sockets.set(url, new this(dispatcher, endpoint));
1591
+ return sockets.get(url);
1909
1592
  }
1910
1593
  });
1911
1594
 
1912
- assign(EventSource.prototype, Deferrable);
1595
+ Object.assign(EventSource.prototype, Deferrable);
1913
1596
 
1914
1597
  module.exports = EventSource;
1915
1598
 
@@ -1927,18 +1610,16 @@ module.exports = EventSource;
1927
1610
  "use strict";
1928
1611
  /* WEBPACK VAR INJECTION */(function(global) {
1929
1612
 
1930
- var Class = __webpack_require__(/*! ../util/class */ "./src/util/class.js"),
1931
- URI = __webpack_require__(/*! ../util/uri */ "./src/util/uri.js"),
1932
- copyObject = __webpack_require__(/*! ../util/copy_object */ "./src/util/copy_object.js"),
1933
- assign = __webpack_require__(/*! ../util/assign */ "./src/util/assign.js"),
1934
- toJSON = __webpack_require__(/*! ../util/to_json */ "./src/util/to_json.js"),
1935
- Transport = __webpack_require__(/*! ./transport */ "./src/transport/transport.js");
1613
+ var Class = __webpack_require__(/*! ../util/class */ "./src/util/class.js"),
1614
+ URI = __webpack_require__(/*! ../util/uri */ "./src/util/uri.js"),
1615
+ toJSON = __webpack_require__(/*! ../util/to_json */ "./src/util/to_json.js"),
1616
+ Transport = __webpack_require__(/*! ./transport */ "./src/transport/transport.js");
1936
1617
 
1937
- var JSONP = assign(Class(Transport, {
1938
- encode: function(messages) {
1939
- var url = copyObject(this.endpoint);
1940
- url.query.message = toJSON(messages);
1941
- url.query.jsonp = '__jsonp' + JSONP._cbCount + '__';
1618
+ var JSONP = Object.assign(Class(Transport, {
1619
+ encode: function(messages) {
1620
+ var url = URI.clone(this.endpoint);
1621
+ url.searchParams.set('message', toJSON(messages));
1622
+ url.searchParams.set('jsonp', '__jsonp' + JSONP._cbCount + '__');
1942
1623
  return URI.stringify(url);
1943
1624
  },
1944
1625
 
@@ -1946,11 +1627,11 @@ var JSONP = assign(Class(Transport, {
1946
1627
  var head = document.getElementsByTagName('head')[0],
1947
1628
  script = document.createElement('script'),
1948
1629
  callbackName = JSONP.getCallbackName(),
1949
- endpoint = copyObject(this.endpoint),
1630
+ endpoint = URI.clone(this.endpoint),
1950
1631
  self = this;
1951
1632
 
1952
- endpoint.query.message = toJSON(messages);
1953
- endpoint.query.jsonp = callbackName;
1633
+ endpoint.searchParams.set('message', toJSON(messages));
1634
+ endpoint.searchParams.set('jsonp', callbackName);
1954
1635
 
1955
1636
  var cleanup = function() {
1956
1637
  if (!global[callbackName]) return false;
@@ -2006,14 +1687,12 @@ module.exports = JSONP;
2006
1687
 
2007
1688
  var Class = __webpack_require__(/*! ../util/class */ "./src/util/class.js"),
2008
1689
  Cookie = __webpack_require__(/*! ../util/cookies */ "./src/util/cookies/browser_cookies.js").Cookie,
2009
- Promise = __webpack_require__(/*! ../util/promise */ "./src/util/promise.js"),
2010
1690
  array = __webpack_require__(/*! ../util/array */ "./src/util/array.js"),
2011
- assign = __webpack_require__(/*! ../util/assign */ "./src/util/assign.js"),
2012
1691
  Logging = __webpack_require__(/*! ../mixins/logging */ "./src/mixins/logging.js"),
2013
1692
  Timeouts = __webpack_require__(/*! ../mixins/timeouts */ "./src/mixins/timeouts.js"),
2014
1693
  Channel = __webpack_require__(/*! ../protocol/channel */ "./src/protocol/channel.js");
2015
1694
 
2016
- var Transport = assign(Class({ className: 'Transport',
1695
+ var Transport = Object.assign(Class({ className: 'Transport',
2017
1696
  DEFAULT_PORTS: { 'http:': 80, 'https:': 443, 'ws:': 80, 'wss:': 443 },
2018
1697
  MAX_DELAY: 0,
2019
1698
 
@@ -2023,10 +1702,11 @@ var Transport = assign(Class({ className: 'Transport',
2023
1702
  this._dispatcher = dispatcher;
2024
1703
  this.endpoint = endpoint;
2025
1704
  this._outbox = [];
2026
- this._proxy = assign({}, this._dispatcher.proxy);
1705
+ this._proxy = Object.assign({}, this._dispatcher.proxy);
2027
1706
 
2028
- if (!this._proxy.origin)
1707
+ if (!this._proxy.origin) {
2029
1708
  this._proxy.origin = this._findProxy();
1709
+ }
2030
1710
  },
2031
1711
 
2032
1712
  close: function() {},
@@ -2044,11 +1724,12 @@ var Transport = assign(Class({ className: 'Transport',
2044
1724
  this._outbox.push(message);
2045
1725
  this._flushLargeBatch();
2046
1726
 
2047
- if (message.channel === Channel.HANDSHAKE)
1727
+ if (message.channel === Channel.HANDSHAKE) {
2048
1728
  return this._publish(0.01);
2049
-
2050
- if (message.channel === Channel.CONNECT)
1729
+ }
1730
+ if (message.channel === Channel.CONNECT) {
2051
1731
  this._connectMessage = message;
1732
+ }
2052
1733
 
2053
1734
  return this._publish(this.MAX_DELAY);
2054
1735
  },
@@ -2075,8 +1756,9 @@ var Transport = assign(Class({ className: 'Transport',
2075
1756
  _flush: function() {
2076
1757
  this.removeTimeout('publish');
2077
1758
 
2078
- if (this._outbox.length > 1 && this._connectMessage)
1759
+ if (this._outbox.length > 1 && this._connectMessage) {
2079
1760
  this._connectMessage.advice = { timeout: 0 };
1761
+ }
2080
1762
 
2081
1763
  this._resolvePromise(this.request(this._outbox));
2082
1764
 
@@ -2102,8 +1784,9 @@ var Transport = assign(Class({ className: 'Transport',
2102
1784
  this.debug('Client ? received from ? via ?: ?',
2103
1785
  this._dispatcher.clientId, this.endpoint.href, this.connectionType, replies);
2104
1786
 
2105
- for (var i = 0, n = replies.length; i < n; i++)
2106
- this._dispatcher.handleResponse(replies[i]);
1787
+ for (let reply of replies) {
1788
+ this._dispatcher.handleResponse(reply);
1789
+ }
2107
1790
  },
2108
1791
 
2109
1792
  _handleError: function(messages, immediate) {
@@ -2112,8 +1795,9 @@ var Transport = assign(Class({ className: 'Transport',
2112
1795
  this.debug('Client ? failed to send to ? via ?: ?',
2113
1796
  this._dispatcher.clientId, this.endpoint.href, this.connectionType, messages);
2114
1797
 
2115
- for (var i = 0, n = messages.length; i < n; i++)
2116
- this._dispatcher.handleError(messages[i]);
1798
+ for (let message of messages) {
1799
+ this._dispatcher.handleError(message);
1800
+ }
2117
1801
  },
2118
1802
 
2119
1803
  _getCookies: function() {
@@ -2135,8 +1819,8 @@ var Transport = assign(Class({ className: 'Transport',
2135
1819
  if (!setCookie || !cookies) return;
2136
1820
  setCookie = [].concat(setCookie);
2137
1821
 
2138
- for (var i = 0, n = setCookie.length; i < n; i++) {
2139
- cookie = Cookie.parse(setCookie[i]);
1822
+ for (let cookieStr of setCookie) {
1823
+ cookie = Cookie.parse(cookieStr);
2140
1824
  cookies.setCookieSync(cookie, url);
2141
1825
  }
2142
1826
  },
@@ -2155,17 +1839,19 @@ var Transport = assign(Class({ className: 'Transport',
2155
1839
  if (name === 'http_proxy' && env.REQUEST_METHOD) {
2156
1840
  keys = Object.keys(env).filter(function(k) { return /^http_proxy$/i.test(k) });
2157
1841
  if (keys.length === 1) {
2158
- if (keys[0] === name && env[upcase] === undefined)
1842
+ if (keys[0] === name && env[upcase] === undefined) {
2159
1843
  proxy = env[name];
1844
+ }
2160
1845
  } else if (keys.length > 1) {
2161
1846
  proxy = env[name];
2162
1847
  }
2163
1848
  proxy = proxy || env['CGI_' + upcase];
2164
1849
  } else {
2165
1850
  proxy = env[name] || env[upcase];
2166
- if (proxy && !env[name])
1851
+ if (proxy && !env[name]) {
2167
1852
  console.warn('The environment variable ' + upcase +
2168
1853
  ' is discouraged. Use ' + name + '.');
1854
+ }
2169
1855
  }
2170
1856
  return proxy;
2171
1857
  }
@@ -2178,9 +1864,9 @@ var Transport = assign(Class({ className: 'Transport',
2178
1864
  var connType = pair[0], klass = pair[1],
2179
1865
  connEndpoint = dispatcher.endpointFor(connType);
2180
1866
 
2181
- if (array.indexOf(disabled, connType) >= 0)
1867
+ if (array.indexOf(disabled, connType) >= 0) {
2182
1868
  return resume();
2183
-
1869
+ }
2184
1870
  if (array.indexOf(allowed, connType) < 0) {
2185
1871
  klass.isUsable(dispatcher, connEndpoint, function() {});
2186
1872
  return resume();
@@ -2208,15 +1894,16 @@ var Transport = assign(Class({ className: 'Transport',
2208
1894
  disable: function(feature) {
2209
1895
  if (feature !== 'autodisconnect') return;
2210
1896
 
2211
- for (var i = 0; i < this._transports.length; i++)
2212
- this._transports[i][1]._unloaded = false;
1897
+ for (let transport of this._transports) {
1898
+ transport[1]._unloaded = false;
1899
+ }
2213
1900
  },
2214
1901
 
2215
1902
  _transports: []
2216
1903
  });
2217
1904
 
2218
- assign(Transport.prototype, Logging);
2219
- assign(Transport.prototype, Timeouts);
1905
+ Object.assign(Transport.prototype, Logging);
1906
+ Object.assign(Transport.prototype, Timeouts);
2220
1907
 
2221
1908
  module.exports = Transport;
2222
1909
 
@@ -2234,18 +1921,15 @@ module.exports = Transport;
2234
1921
  /* WEBPACK VAR INJECTION */(function(global) {
2235
1922
 
2236
1923
  var Class = __webpack_require__(/*! ../util/class */ "./src/util/class.js"),
2237
- Promise = __webpack_require__(/*! ../util/promise */ "./src/util/promise.js"),
2238
1924
  Set = __webpack_require__(/*! ../util/set */ "./src/util/set.js"),
2239
1925
  URI = __webpack_require__(/*! ../util/uri */ "./src/util/uri.js"),
2240
1926
  browser = __webpack_require__(/*! ../util/browser */ "./src/util/browser/event.js"),
2241
- copyObject = __webpack_require__(/*! ../util/copy_object */ "./src/util/copy_object.js"),
2242
- assign = __webpack_require__(/*! ../util/assign */ "./src/util/assign.js"),
2243
1927
  toJSON = __webpack_require__(/*! ../util/to_json */ "./src/util/to_json.js"),
2244
1928
  ws = __webpack_require__(/*! ../util/websocket */ "./src/util/websocket/browser_websocket.js"),
2245
1929
  Deferrable = __webpack_require__(/*! ../mixins/deferrable */ "./src/mixins/deferrable.js"),
2246
1930
  Transport = __webpack_require__(/*! ./transport */ "./src/transport/transport.js");
2247
1931
 
2248
- var WebSocket = assign(Class(Transport, {
1932
+ var WebSocket = Object.assign(Class(Transport, {
2249
1933
  UNCONNECTED: 1,
2250
1934
  CONNECTING: 2,
2251
1935
  CONNECTED: 3,
@@ -2260,7 +1944,7 @@ var WebSocket = assign(Class(Transport, {
2260
1944
 
2261
1945
  request: function(messages) {
2262
1946
  this._pending = this._pending || new Set();
2263
- for (var i = 0, n = messages.length; i < n; i++) this._pending.add(messages[i]);
1947
+ for (let message of messages) this._pending.add(message);
2264
1948
 
2265
1949
  var self = this;
2266
1950
 
@@ -2310,7 +1994,7 @@ var WebSocket = assign(Class(Transport, {
2310
1994
  delete self._socket;
2311
1995
  self._state = self.UNCONNECTED;
2312
1996
 
2313
- var pending = self._pending ? self._pending.toArray() : [];
1997
+ var pending = self._pending ? [...self._pending] : [];
2314
1998
  delete self._pending;
2315
1999
 
2316
2000
  if (wasConnected || self._everConnected) {
@@ -2329,9 +2013,9 @@ var WebSocket = assign(Class(Transport, {
2329
2013
 
2330
2014
  replies = [].concat(replies);
2331
2015
 
2332
- for (var i = 0, n = replies.length; i < n; i++) {
2333
- if (replies[i].successful === undefined) continue;
2334
- self._pending.remove(replies[i]);
2016
+ for (let reply of replies) {
2017
+ if (reply.successful === undefined) continue;
2018
+ self._pending.remove(reply);
2335
2019
  }
2336
2020
  self._receive(replies);
2337
2021
  };
@@ -2366,13 +2050,16 @@ var WebSocket = assign(Class(Transport, {
2366
2050
  },
2367
2051
 
2368
2052
  create: function(dispatcher, endpoint) {
2369
- var sockets = dispatcher.transports.websocket = dispatcher.transports.websocket || {};
2370
- sockets[endpoint.href] = sockets[endpoint.href] || new this(dispatcher, endpoint);
2371
- return sockets[endpoint.href];
2053
+ var transports = dispatcher.transports,
2054
+ sockets = transports.websocket = transports.websocket || new Map();
2055
+
2056
+ if (!sockets.has(endpoint.href)) sockets.set(endpoint.href, new this(dispatcher, endpoint));
2057
+
2058
+ return sockets.get(endpoint.href);
2372
2059
  },
2373
2060
 
2374
2061
  getSocketUrl: function(endpoint) {
2375
- endpoint = copyObject(endpoint);
2062
+ endpoint = URI.clone(endpoint);
2376
2063
  endpoint.protocol = this.PROTOCOLS[endpoint.protocol];
2377
2064
  return URI.stringify(endpoint);
2378
2065
  },
@@ -2382,12 +2069,13 @@ var WebSocket = assign(Class(Transport, {
2382
2069
  }
2383
2070
  });
2384
2071
 
2385
- assign(WebSocket.prototype, Deferrable);
2072
+ Object.assign(WebSocket.prototype, Deferrable);
2386
2073
 
2387
2074
  if (browser.Event && global.onbeforeunload !== undefined) {
2388
2075
  browser.Event.on(global, 'beforeunload', function() {
2389
- if (WebSocket._unloaded === undefined)
2076
+ if (WebSocket._unloaded === undefined) {
2390
2077
  WebSocket._unloaded = true;
2078
+ }
2391
2079
  });
2392
2080
  }
2393
2081
 
@@ -2410,11 +2098,10 @@ module.exports = WebSocket;
2410
2098
  var Class = __webpack_require__(/*! ../util/class */ "./src/util/class.js"),
2411
2099
  URI = __webpack_require__(/*! ../util/uri */ "./src/util/uri.js"),
2412
2100
  browser = __webpack_require__(/*! ../util/browser */ "./src/util/browser/event.js"),
2413
- assign = __webpack_require__(/*! ../util/assign */ "./src/util/assign.js"),
2414
2101
  toJSON = __webpack_require__(/*! ../util/to_json */ "./src/util/to_json.js"),
2415
2102
  Transport = __webpack_require__(/*! ./transport */ "./src/transport/transport.js");
2416
2103
 
2417
- var XHR = assign(Class(Transport, {
2104
+ var XHR = Object.assign(Class(Transport, {
2418
2105
  encode: function(messages) {
2419
2106
  return toJSON(messages);
2420
2107
  },
@@ -2439,14 +2126,14 @@ var XHR = assign(Class(Transport, {
2439
2126
  xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
2440
2127
 
2441
2128
  var headers = this._dispatcher.headers;
2442
- for (var key in headers) {
2443
- if (!headers.hasOwnProperty(key)) continue;
2444
- xhr.setRequestHeader(key, headers[key]);
2129
+ for (let [key, value] of Object.entries(headers)) {
2130
+ xhr.setRequestHeader(key, value);
2445
2131
  }
2446
2132
 
2447
2133
  var abort = function() { xhr.abort() };
2448
- if (global.onbeforeunload !== undefined)
2134
+ if (global.onbeforeunload !== undefined) {
2449
2135
  browser.Event.on(global, 'beforeunload', abort);
2136
+ }
2450
2137
 
2451
2138
  xhr.onreadystatechange = function() {
2452
2139
  if (!xhr || xhr.readyState !== 4) return;
@@ -2456,8 +2143,9 @@ var XHR = assign(Class(Transport, {
2456
2143
  text = xhr.responseText,
2457
2144
  successful = (status >= 200 && status < 300) || status === 304 || status === 1223;
2458
2145
 
2459
- if (global.onbeforeunload !== undefined)
2146
+ if (global.onbeforeunload !== undefined) {
2460
2147
  browser.Event.detach(global, 'beforeunload', abort);
2148
+ }
2461
2149
 
2462
2150
  xhr.onreadystatechange = function() {};
2463
2151
  xhr = null;
@@ -2468,10 +2156,11 @@ var XHR = assign(Class(Transport, {
2468
2156
  replies = JSON.parse(text);
2469
2157
  } catch (error) {}
2470
2158
 
2471
- if (replies)
2159
+ if (replies) {
2472
2160
  self._receive(replies);
2473
- else
2161
+ } else {
2474
2162
  self._handleError(messages);
2163
+ }
2475
2164
  };
2476
2165
 
2477
2166
  xhr.send(this.encode(messages));
@@ -2505,8 +2194,9 @@ module.exports = XHR;
2505
2194
  module.exports = {
2506
2195
  commonElement: function(lista, listb) {
2507
2196
  for (var i = 0, n = lista.length; i < n; i++) {
2508
- if (this.indexOf(listb, lista[i]) !== -1)
2197
+ if (this.indexOf(listb, lista[i]) !== -1) {
2509
2198
  return lista[i];
2199
+ }
2510
2200
  }
2511
2201
  return null;
2512
2202
  },
@@ -2529,9 +2219,8 @@ module.exports = {
2529
2219
  result.push(callback.call(context || null, object[i], i));
2530
2220
  }
2531
2221
  } else {
2532
- for (var key in object) {
2533
- if (!object.hasOwnProperty(key)) continue;
2534
- result.push(callback.call(context || null, key, object[key]));
2222
+ for (let [key, value] of Object.entries(object)) {
2223
+ result.push(callback.call(context || null, key, value));
2535
2224
  }
2536
2225
  }
2537
2226
  return result;
@@ -2541,8 +2230,9 @@ module.exports = {
2541
2230
  if (array.filter) return array.filter(callback, context);
2542
2231
  var result = [];
2543
2232
  for (var i = 0, n = array.length; i < n; i++) {
2544
- if (callback.call(context || null, array[i], i))
2233
+ if (callback.call(context || null, array[i], i)) {
2545
2234
  result.push(array[i]);
2235
+ }
2546
2236
  }
2547
2237
  return result;
2548
2238
  },
@@ -2576,34 +2266,6 @@ module.exports = {
2576
2266
  };
2577
2267
 
2578
2268
 
2579
- /***/ }),
2580
-
2581
- /***/ "./src/util/assign.js":
2582
- /*!****************************!*\
2583
- !*** ./src/util/assign.js ***!
2584
- \****************************/
2585
- /*! no static exports found */
2586
- /***/ (function(module, exports, __webpack_require__) {
2587
-
2588
- "use strict";
2589
-
2590
-
2591
- var forEach = Array.prototype.forEach,
2592
- hasOwn = Object.prototype.hasOwnProperty;
2593
-
2594
- module.exports = function(target) {
2595
- forEach.call(arguments, function(source, i) {
2596
- if (i === 0) return;
2597
-
2598
- for (var key in source) {
2599
- if (hasOwn.call(source, key)) target[key] = source[key];
2600
- }
2601
- });
2602
-
2603
- return target;
2604
- };
2605
-
2606
-
2607
2269
  /***/ }),
2608
2270
 
2609
2271
  /***/ "./src/util/browser/event.js":
@@ -2614,7 +2276,7 @@ module.exports = function(target) {
2614
2276
  /***/ (function(module, exports, __webpack_require__) {
2615
2277
 
2616
2278
  "use strict";
2617
- /* WEBPACK VAR INJECTION */(function(global) {
2279
+
2618
2280
 
2619
2281
  var Event = {
2620
2282
  _registry: [],
@@ -2622,10 +2284,11 @@ var Event = {
2622
2284
  on: function(element, eventName, callback, context) {
2623
2285
  var wrapped = function() { callback.call(context) };
2624
2286
 
2625
- if (element.addEventListener)
2287
+ if (element.addEventListener) {
2626
2288
  element.addEventListener(eventName, wrapped, false);
2627
- else
2289
+ } else {
2628
2290
  element.attachEvent('on' + eventName, wrapped);
2291
+ }
2629
2292
 
2630
2293
  this._registry.push({
2631
2294
  _element: element,
@@ -2647,10 +2310,11 @@ var Event = {
2647
2310
  (context && context !== register._context))
2648
2311
  continue;
2649
2312
 
2650
- if (register._element.removeEventListener)
2313
+ if (register._element.removeEventListener) {
2651
2314
  register._element.removeEventListener(register._type, register._handler, false);
2652
- else
2315
+ } else {
2653
2316
  register._element.detachEvent('on' + register._type, register._handler);
2317
+ }
2654
2318
 
2655
2319
  this._registry.splice(i,1);
2656
2320
  register = null;
@@ -2658,14 +2322,10 @@ var Event = {
2658
2322
  }
2659
2323
  };
2660
2324
 
2661
- if (global.onunload !== undefined)
2662
- Event.on(global, 'unload', Event.detach, Event);
2663
-
2664
2325
  module.exports = {
2665
2326
  Event: Event
2666
2327
  };
2667
2328
 
2668
- /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../../node_modules/webpack/buildin/global.js */ "./node_modules/webpack/buildin/global.js")))
2669
2329
 
2670
2330
  /***/ }),
2671
2331
 
@@ -2679,8 +2339,6 @@ module.exports = {
2679
2339
  "use strict";
2680
2340
 
2681
2341
 
2682
- var assign = __webpack_require__(/*! ./assign */ "./src/util/assign.js");
2683
-
2684
2342
  module.exports = function(parent, methods) {
2685
2343
  if (typeof parent !== 'function') {
2686
2344
  methods = parent;
@@ -2696,7 +2354,7 @@ module.exports = function(parent, methods) {
2696
2354
  bridge.prototype = parent.prototype;
2697
2355
 
2698
2356
  klass.prototype = new bridge();
2699
- assign(klass.prototype, methods);
2357
+ Object.assign(klass.prototype, methods);
2700
2358
 
2701
2359
  return klass;
2702
2360
  };
@@ -2712,7 +2370,7 @@ module.exports = function(parent, methods) {
2712
2370
  /***/ (function(module, exports) {
2713
2371
 
2714
2372
  module.exports = {
2715
- VERSION: '1.4.0',
2373
+ VERSION: '1.4.2',
2716
2374
 
2717
2375
  BAYEUX_VERSION: '1.0',
2718
2376
  ID_LENGTH: 160,
@@ -2738,37 +2396,6 @@ module.exports = {
2738
2396
  module.exports = {};
2739
2397
 
2740
2398
 
2741
- /***/ }),
2742
-
2743
- /***/ "./src/util/copy_object.js":
2744
- /*!*********************************!*\
2745
- !*** ./src/util/copy_object.js ***!
2746
- \*********************************/
2747
- /*! no static exports found */
2748
- /***/ (function(module, exports, __webpack_require__) {
2749
-
2750
- "use strict";
2751
-
2752
-
2753
- var copyObject = function(object) {
2754
- var clone, i, key;
2755
- if (object instanceof Array) {
2756
- clone = [];
2757
- i = object.length;
2758
- while (i--) clone[i] = copyObject(object[i]);
2759
- return clone;
2760
- } else if (typeof object === 'object') {
2761
- clone = (object === null) ? null : {};
2762
- for (key in object) clone[key] = copyObject(object[key]);
2763
- return clone;
2764
- } else {
2765
- return object;
2766
- }
2767
- };
2768
-
2769
- module.exports = copyObject;
2770
-
2771
-
2772
2399
  /***/ }),
2773
2400
 
2774
2401
  /***/ "./src/util/event_emitter.js":
@@ -2951,190 +2578,6 @@ EventEmitter.prototype.listeners = function(type) {
2951
2578
  };
2952
2579
 
2953
2580
 
2954
- /***/ }),
2955
-
2956
- /***/ "./src/util/promise.js":
2957
- /*!*****************************!*\
2958
- !*** ./src/util/promise.js ***!
2959
- \*****************************/
2960
- /*! no static exports found */
2961
- /***/ (function(module, exports, __webpack_require__) {
2962
-
2963
- "use strict";
2964
-
2965
-
2966
- var asap = __webpack_require__(/*! asap */ "./node_modules/asap/browser-asap.js");
2967
-
2968
- var PENDING = -1,
2969
- FULFILLED = 0,
2970
- REJECTED = 1;
2971
-
2972
- var Promise = function(task) {
2973
- this._state = PENDING;
2974
- this._value = null;
2975
- this._defer = [];
2976
-
2977
- execute(this, task);
2978
- };
2979
-
2980
- Promise.prototype.then = function(onFulfilled, onRejected) {
2981
- var promise = new Promise();
2982
-
2983
- var deferred = {
2984
- promise: promise,
2985
- onFulfilled: onFulfilled,
2986
- onRejected: onRejected
2987
- };
2988
-
2989
- if (this._state === PENDING)
2990
- this._defer.push(deferred);
2991
- else
2992
- propagate(this, deferred);
2993
-
2994
- return promise;
2995
- };
2996
-
2997
- Promise.prototype['catch'] = function(onRejected) {
2998
- return this.then(null, onRejected);
2999
- };
3000
-
3001
- var execute = function(promise, task) {
3002
- if (typeof task !== 'function') return;
3003
-
3004
- var calls = 0;
3005
-
3006
- var resolvePromise = function(value) {
3007
- if (calls++ === 0) resolve(promise, value);
3008
- };
3009
-
3010
- var rejectPromise = function(reason) {
3011
- if (calls++ === 0) reject(promise, reason);
3012
- };
3013
-
3014
- try {
3015
- task(resolvePromise, rejectPromise);
3016
- } catch (error) {
3017
- rejectPromise(error);
3018
- }
3019
- };
3020
-
3021
- var propagate = function(promise, deferred) {
3022
- var state = promise._state,
3023
- value = promise._value,
3024
- next = deferred.promise,
3025
- handler = [deferred.onFulfilled, deferred.onRejected][state],
3026
- pass = [resolve, reject][state];
3027
-
3028
- if (typeof handler !== 'function')
3029
- return pass(next, value);
3030
-
3031
- asap(function() {
3032
- try {
3033
- resolve(next, handler(value));
3034
- } catch (error) {
3035
- reject(next, error);
3036
- }
3037
- });
3038
- };
3039
-
3040
- var resolve = function(promise, value) {
3041
- if (promise === value)
3042
- return reject(promise, new TypeError('Recursive promise chain detected'));
3043
-
3044
- var then;
3045
-
3046
- try {
3047
- then = getThen(value);
3048
- } catch (error) {
3049
- return reject(promise, error);
3050
- }
3051
-
3052
- if (!then) return fulfill(promise, value);
3053
-
3054
- execute(promise, function(resolvePromise, rejectPromise) {
3055
- then.call(value, resolvePromise, rejectPromise);
3056
- });
3057
- };
3058
-
3059
- var getThen = function(value) {
3060
- var type = typeof value,
3061
- then = (type === 'object' || type === 'function') && value && value.then;
3062
-
3063
- return (typeof then === 'function')
3064
- ? then
3065
- : null;
3066
- };
3067
-
3068
- var fulfill = function(promise, value) {
3069
- settle(promise, FULFILLED, value);
3070
- };
3071
-
3072
- var reject = function(promise, reason) {
3073
- settle(promise, REJECTED, reason);
3074
- };
3075
-
3076
- var settle = function(promise, state, value) {
3077
- var defer = promise._defer, i = 0;
3078
-
3079
- promise._state = state;
3080
- promise._value = value;
3081
- promise._defer = null;
3082
-
3083
- if (defer.length === 0) return;
3084
- while (i < defer.length) propagate(promise, defer[i++]);
3085
- };
3086
-
3087
- Promise.resolve = function(value) {
3088
- try {
3089
- if (getThen(value)) return value;
3090
- } catch (error) {
3091
- return Promise.reject(error);
3092
- }
3093
-
3094
- return new Promise(function(resolve, reject) { resolve(value) });
3095
- };
3096
-
3097
- Promise.reject = function(reason) {
3098
- return new Promise(function(resolve, reject) { reject(reason) });
3099
- };
3100
-
3101
- Promise.all = function(promises) {
3102
- return new Promise(function(resolve, reject) {
3103
- var list = [], n = promises.length, i;
3104
-
3105
- if (n === 0) return resolve(list);
3106
-
3107
- var push = function(promise, i) {
3108
- Promise.resolve(promise).then(function(value) {
3109
- list[i] = value;
3110
- if (--n === 0) resolve(list);
3111
- }, reject);
3112
- };
3113
-
3114
- for (i = 0; i < n; i++) push(promises[i], i);
3115
- });
3116
- };
3117
-
3118
- Promise.race = function(promises) {
3119
- return new Promise(function(resolve, reject) {
3120
- for (var i = 0, n = promises.length; i < n; i++)
3121
- Promise.resolve(promises[i]).then(resolve, reject);
3122
- });
3123
- };
3124
-
3125
- Promise.deferred = function() {
3126
- var tuple = {};
3127
-
3128
- tuple.promise = new Promise(function(resolve, reject) {
3129
- tuple.resolve = resolve;
3130
- tuple.reject = reject;
3131
- });
3132
- return tuple;
3133
- };
3134
-
3135
- module.exports = Promise;
3136
-
3137
-
3138
2581
  /***/ }),
3139
2582
 
3140
2583
  /***/ "./src/util/set.js":
@@ -3151,48 +2594,36 @@ var Class = __webpack_require__(/*! ./class */ "./src/util/class.js");
3151
2594
 
3152
2595
  module.exports = Class({
3153
2596
  initialize: function() {
3154
- this._index = {};
2597
+ this._index = new Map();
3155
2598
  },
3156
2599
 
3157
2600
  add: function(item) {
3158
2601
  var key = (item.id !== undefined) ? item.id : item;
3159
- if (this._index.hasOwnProperty(key)) return false;
3160
- this._index[key] = item;
2602
+ if (this._index.has(key)) return false;
2603
+ this._index.set(key, item);
3161
2604
  return true;
3162
2605
  },
3163
2606
 
3164
- forEach: function(block, context) {
3165
- for (var key in this._index) {
3166
- if (this._index.hasOwnProperty(key))
3167
- block.call(context, this._index[key]);
3168
- }
2607
+ [Symbol.iterator]: function() {
2608
+ return this._index.values();
3169
2609
  },
3170
2610
 
3171
2611
  isEmpty: function() {
3172
- for (var key in this._index) {
3173
- if (this._index.hasOwnProperty(key)) return false;
3174
- }
3175
- return true;
2612
+ return this._index.size === 0;
3176
2613
  },
3177
2614
 
3178
2615
  member: function(item) {
3179
- for (var key in this._index) {
3180
- if (this._index[key] === item) return true;
2616
+ for (let value of this._index.values()) {
2617
+ if (value === item) return true;
3181
2618
  }
3182
2619
  return false;
3183
2620
  },
3184
2621
 
3185
2622
  remove: function(item) {
3186
2623
  var key = (item.id !== undefined) ? item.id : item;
3187
- var removed = this._index[key];
3188
- delete this._index[key];
2624
+ var removed = this._index.get(key);
2625
+ this._index.delete(key);
3189
2626
  return removed;
3190
- },
3191
-
3192
- toArray: function() {
3193
- var array = [];
3194
- this.forEach(function(item) { array.push(item) });
3195
- return array;
3196
2627
  }
3197
2628
  });
3198
2629
 
@@ -3232,7 +2663,7 @@ module.exports = function(object) {
3232
2663
 
3233
2664
  module.exports = {
3234
2665
  isURI: function(uri) {
3235
- return uri && uri.protocol && uri.host && uri.path;
2666
+ return uri && uri.protocol && uri.host && uri.pathname;
3236
2667
  },
3237
2668
 
3238
2669
  isSameOrigin: function(uri) {
@@ -3241,81 +2672,22 @@ module.exports = {
3241
2672
  uri.port === location.port;
3242
2673
  },
3243
2674
 
3244
- parse: function(url) {
2675
+ parse: function(url, base) {
3245
2676
  if (typeof url !== 'string') return url;
3246
- var uri = {}, parts, query, pairs, i, n, data;
3247
-
3248
- var consume = function(name, pattern) {
3249
- url = url.replace(pattern, function(match) {
3250
- uri[name] = match;
3251
- return '';
3252
- });
3253
- uri[name] = uri[name] || '';
3254
- };
3255
2677
 
3256
- consume('protocol', /^[a-z]+\:/i);
3257
- consume('host', /^\/\/[^\/\?#]+/);
3258
-
3259
- if (!/^\//.test(url) && !uri.host)
3260
- url = location.pathname.replace(/[^\/]*$/, '') + url;
3261
-
3262
- consume('pathname', /^[^\?#]*/);
3263
- consume('search', /^\?[^#]*/);
3264
- consume('hash', /^#.*/);
3265
-
3266
- uri.protocol = uri.protocol || location.protocol;
3267
-
3268
- if (uri.host) {
3269
- uri.host = uri.host.substr(2);
3270
-
3271
- if (/@/.test(uri.host)) {
3272
- uri.auth = uri.host.split('@')[0];
3273
- uri.host = uri.host.split('@')[1];
3274
- }
3275
- parts = uri.host.match(/^\[([^\]]+)\]|^[^:]+/);
3276
- uri.hostname = parts[1] || parts[0];
3277
- uri.port = (uri.host.match(/:(\d+)$/) || [])[1] || '';
2678
+ if (typeof location === 'undefined') {
2679
+ return new URL(url, base);
3278
2680
  } else {
3279
- uri.host = location.host;
3280
- uri.hostname = location.hostname;
3281
- uri.port = location.port;
3282
- }
3283
-
3284
- uri.pathname = uri.pathname || '/';
3285
- uri.path = uri.pathname + uri.search;
3286
-
3287
- query = uri.search.replace(/^\?/, '');
3288
- pairs = query ? query.split('&') : [];
3289
- data = {};
3290
-
3291
- for (i = 0, n = pairs.length; i < n; i++) {
3292
- parts = pairs[i].split('=');
3293
- data[decodeURIComponent(parts[0] || '')] = decodeURIComponent(parts[1] || '');
2681
+ return new URL(url, base || location.href);
3294
2682
  }
3295
-
3296
- uri.query = data;
3297
-
3298
- uri.href = this.stringify(uri);
3299
- return uri;
3300
2683
  },
3301
2684
 
3302
2685
  stringify: function(uri) {
3303
- var auth = uri.auth ? uri.auth + '@' : '',
3304
- string = uri.protocol + '//' + auth + uri.host;
3305
-
3306
- string += uri.pathname + this.queryString(uri.query) + (uri.hash || '');
3307
-
3308
- return string;
2686
+ return (typeof uri === 'string') ? uri : uri.href;
3309
2687
  },
3310
2688
 
3311
- queryString: function(query) {
3312
- var pairs = [];
3313
- for (var key in query) {
3314
- if (!query.hasOwnProperty(key)) continue;
3315
- pairs.push(encodeURIComponent(key) + '=' + encodeURIComponent(query[key]));
3316
- }
3317
- if (pairs.length === 0) return '';
3318
- return '?' + pairs.join('&');
2689
+ clone: function(url) {
2690
+ return this.parse(url.href);
3319
2691
  }
3320
2692
  };
3321
2693
 
@@ -3335,9 +2707,10 @@ module.exports = {
3335
2707
  var array = __webpack_require__(/*! ./array */ "./src/util/array.js");
3336
2708
 
3337
2709
  module.exports = function(options, validKeys) {
3338
- for (var key in options) {
3339
- if (array.indexOf(validKeys, key) < 0)
2710
+ for (let key of Object.keys(options)) {
2711
+ if (array.indexOf(validKeys, key) < 0) {
3340
2712
  throw new Error('Unrecognized option: ' + key);
2713
+ }
3341
2714
  }
3342
2715
  };
3343
2716