es6-promise-rails 3.0.2 → 3.2.1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7632e97b744ae3450cce48b3e73cbdeab093263c
4
- data.tar.gz: c2b71499074c585dccf1cda166d0d5263996d8dc
3
+ metadata.gz: dd644506509c986b2a5acfcdaae0feae1cb55782
4
+ data.tar.gz: 5190aeecaf25d974d8d1e0adbff829520a7fcb8b
5
5
  SHA512:
6
- metadata.gz: 8adb1931309cbc40e9c001c45f4a5bae4266ac29ae4737467f54f24abba4c71876382d44bf31182b528da2c7511280c8c74dd9bbb5dc0c37acf6fe5f9dac34fd
7
- data.tar.gz: 3b600d62d924ba4edf4fb7397c4894d403a8645deb15bf23c11ade1c4c7101f75173af58784b3e3a9c3ebdd7bb42a5d18f4258827e61342be120988125f8772a
6
+ metadata.gz: b7822f036fef4a1a23cd4ea87c78b386fa67ee7fd9f773cb2bad2d638a4a9c3e0d31f9d1ac77c306e5ef575c2afc1d8b1763a75e95d505a27ca1435cb4d4cecd
7
+ data.tar.gz: e4f71b4463bd3e827b509856b893a0c690cf2f28ce2728474bfdbec3102771d0358be0de04554f9f9c8d905558ecbd03d7220684c3035253186b047eced433f8
@@ -1,7 +1,7 @@
1
1
  module E6
2
2
  module Promise
3
3
  module Rails
4
- VERSION = '3.0.2'.freeze
4
+ VERSION = '3.2.1'.freeze
5
5
  end
6
6
  end
7
7
  end
@@ -3,7 +3,7 @@
3
3
  * @copyright Copyright (c) 2014 Yehuda Katz, Tom Dale, Stefan Penner and contributors (Conversion to ES6 API by Jake Archibald)
4
4
  * @license Licensed under MIT license
5
5
  * See https://raw.githubusercontent.com/jakearchibald/es6-promise/master/LICENSE
6
- * @version 3.0.2
6
+ * @version 3.2.1
7
7
  */
8
8
 
9
9
  (function() {
@@ -31,7 +31,6 @@
31
31
 
32
32
  var lib$es6$promise$utils$$isArray = lib$es6$promise$utils$$_isArray;
33
33
  var lib$es6$promise$asap$$len = 0;
34
- var lib$es6$promise$asap$$toString = {}.toString;
35
34
  var lib$es6$promise$asap$$vertxNext;
36
35
  var lib$es6$promise$asap$$customSchedulerFn;
37
36
 
@@ -62,7 +61,7 @@
62
61
  var lib$es6$promise$asap$$browserWindow = (typeof window !== 'undefined') ? window : undefined;
63
62
  var lib$es6$promise$asap$$browserGlobal = lib$es6$promise$asap$$browserWindow || {};
64
63
  var lib$es6$promise$asap$$BrowserMutationObserver = lib$es6$promise$asap$$browserGlobal.MutationObserver || lib$es6$promise$asap$$browserGlobal.WebKitMutationObserver;
65
- var lib$es6$promise$asap$$isNode = typeof process !== 'undefined' && {}.toString.call(process) === '[object process]';
64
+ var lib$es6$promise$asap$$isNode = typeof self === 'undefined' && typeof process !== 'undefined' && {}.toString.call(process) === '[object process]';
66
65
 
67
66
  // test for web worker but not in IE10
68
67
  var lib$es6$promise$asap$$isWorker = typeof Uint8ClampedArray !== 'undefined' &&
@@ -150,6 +149,43 @@
150
149
  } else {
151
150
  lib$es6$promise$asap$$scheduleFlush = lib$es6$promise$asap$$useSetTimeout();
152
151
  }
152
+ function lib$es6$promise$then$$then(onFulfillment, onRejection) {
153
+ var parent = this;
154
+
155
+ var child = new this.constructor(lib$es6$promise$$internal$$noop);
156
+
157
+ if (child[lib$es6$promise$$internal$$PROMISE_ID] === undefined) {
158
+ lib$es6$promise$$internal$$makePromise(child);
159
+ }
160
+
161
+ var state = parent._state;
162
+
163
+ if (state) {
164
+ var callback = arguments[state - 1];
165
+ lib$es6$promise$asap$$asap(function(){
166
+ lib$es6$promise$$internal$$invokeCallback(state, child, callback, parent._result);
167
+ });
168
+ } else {
169
+ lib$es6$promise$$internal$$subscribe(parent, child, onFulfillment, onRejection);
170
+ }
171
+
172
+ return child;
173
+ }
174
+ var lib$es6$promise$then$$default = lib$es6$promise$then$$then;
175
+ function lib$es6$promise$promise$resolve$$resolve(object) {
176
+ /*jshint validthis:true */
177
+ var Constructor = this;
178
+
179
+ if (object && typeof object === 'object' && object.constructor === Constructor) {
180
+ return object;
181
+ }
182
+
183
+ var promise = new Constructor(lib$es6$promise$$internal$$noop);
184
+ lib$es6$promise$$internal$$resolve(promise, object);
185
+ return promise;
186
+ }
187
+ var lib$es6$promise$promise$resolve$$default = lib$es6$promise$promise$resolve$$resolve;
188
+ var lib$es6$promise$$internal$$PROMISE_ID = Math.random().toString(36).substring(16);
153
189
 
154
190
  function lib$es6$promise$$internal$$noop() {}
155
191
 
@@ -223,12 +259,12 @@
223
259
  }
224
260
  }
225
261
 
226
- function lib$es6$promise$$internal$$handleMaybeThenable(promise, maybeThenable) {
227
- if (maybeThenable.constructor === promise.constructor) {
262
+ function lib$es6$promise$$internal$$handleMaybeThenable(promise, maybeThenable, then) {
263
+ if (maybeThenable.constructor === promise.constructor &&
264
+ then === lib$es6$promise$then$$default &&
265
+ constructor.resolve === lib$es6$promise$promise$resolve$$default) {
228
266
  lib$es6$promise$$internal$$handleOwnThenable(promise, maybeThenable);
229
267
  } else {
230
- var then = lib$es6$promise$$internal$$getThen(maybeThenable);
231
-
232
268
  if (then === lib$es6$promise$$internal$$GET_THEN_ERROR) {
233
269
  lib$es6$promise$$internal$$reject(promise, lib$es6$promise$$internal$$GET_THEN_ERROR.error);
234
270
  } else if (then === undefined) {
@@ -245,7 +281,7 @@
245
281
  if (promise === value) {
246
282
  lib$es6$promise$$internal$$reject(promise, lib$es6$promise$$internal$$selfFulfillment());
247
283
  } else if (lib$es6$promise$utils$$objectOrFunction(value)) {
248
- lib$es6$promise$$internal$$handleMaybeThenable(promise, value);
284
+ lib$es6$promise$$internal$$handleMaybeThenable(promise, value, lib$es6$promise$$internal$$getThen(value));
249
285
  } else {
250
286
  lib$es6$promise$$internal$$fulfill(promise, value);
251
287
  }
@@ -380,104 +416,18 @@
380
416
  }
381
417
  }
382
418
 
383
- function lib$es6$promise$enumerator$$Enumerator(Constructor, input) {
384
- var enumerator = this;
385
-
386
- enumerator._instanceConstructor = Constructor;
387
- enumerator.promise = new Constructor(lib$es6$promise$$internal$$noop);
388
-
389
- if (enumerator._validateInput(input)) {
390
- enumerator._input = input;
391
- enumerator.length = input.length;
392
- enumerator._remaining = input.length;
393
-
394
- enumerator._init();
395
-
396
- if (enumerator.length === 0) {
397
- lib$es6$promise$$internal$$fulfill(enumerator.promise, enumerator._result);
398
- } else {
399
- enumerator.length = enumerator.length || 0;
400
- enumerator._enumerate();
401
- if (enumerator._remaining === 0) {
402
- lib$es6$promise$$internal$$fulfill(enumerator.promise, enumerator._result);
403
- }
404
- }
405
- } else {
406
- lib$es6$promise$$internal$$reject(enumerator.promise, enumerator._validationError());
407
- }
419
+ var lib$es6$promise$$internal$$id = 0;
420
+ function lib$es6$promise$$internal$$nextId() {
421
+ return lib$es6$promise$$internal$$id++;
408
422
  }
409
423
 
410
- lib$es6$promise$enumerator$$Enumerator.prototype._validateInput = function(input) {
411
- return lib$es6$promise$utils$$isArray(input);
412
- };
413
-
414
- lib$es6$promise$enumerator$$Enumerator.prototype._validationError = function() {
415
- return new Error('Array Methods must be provided an Array');
416
- };
417
-
418
- lib$es6$promise$enumerator$$Enumerator.prototype._init = function() {
419
- this._result = new Array(this.length);
420
- };
421
-
422
- var lib$es6$promise$enumerator$$default = lib$es6$promise$enumerator$$Enumerator;
423
-
424
- lib$es6$promise$enumerator$$Enumerator.prototype._enumerate = function() {
425
- var enumerator = this;
426
-
427
- var length = enumerator.length;
428
- var promise = enumerator.promise;
429
- var input = enumerator._input;
430
-
431
- for (var i = 0; promise._state === lib$es6$promise$$internal$$PENDING && i < length; i++) {
432
- enumerator._eachEntry(input[i], i);
433
- }
434
- };
435
-
436
- lib$es6$promise$enumerator$$Enumerator.prototype._eachEntry = function(entry, i) {
437
- var enumerator = this;
438
- var c = enumerator._instanceConstructor;
439
-
440
- if (lib$es6$promise$utils$$isMaybeThenable(entry)) {
441
- if (entry.constructor === c && entry._state !== lib$es6$promise$$internal$$PENDING) {
442
- entry._onerror = null;
443
- enumerator._settledAt(entry._state, i, entry._result);
444
- } else {
445
- enumerator._willSettleAt(c.resolve(entry), i);
446
- }
447
- } else {
448
- enumerator._remaining--;
449
- enumerator._result[i] = entry;
450
- }
451
- };
452
-
453
- lib$es6$promise$enumerator$$Enumerator.prototype._settledAt = function(state, i, value) {
454
- var enumerator = this;
455
- var promise = enumerator.promise;
456
-
457
- if (promise._state === lib$es6$promise$$internal$$PENDING) {
458
- enumerator._remaining--;
459
-
460
- if (state === lib$es6$promise$$internal$$REJECTED) {
461
- lib$es6$promise$$internal$$reject(promise, value);
462
- } else {
463
- enumerator._result[i] = value;
464
- }
465
- }
466
-
467
- if (enumerator._remaining === 0) {
468
- lib$es6$promise$$internal$$fulfill(promise, enumerator._result);
469
- }
470
- };
471
-
472
- lib$es6$promise$enumerator$$Enumerator.prototype._willSettleAt = function(promise, i) {
473
- var enumerator = this;
424
+ function lib$es6$promise$$internal$$makePromise(promise) {
425
+ promise[lib$es6$promise$$internal$$PROMISE_ID] = lib$es6$promise$$internal$$id++;
426
+ promise._state = undefined;
427
+ promise._result = undefined;
428
+ promise._subscribers = [];
429
+ }
474
430
 
475
- lib$es6$promise$$internal$$subscribe(promise, undefined, function(value) {
476
- enumerator._settledAt(lib$es6$promise$$internal$$FULFILLED, i, value);
477
- }, function(reason) {
478
- enumerator._settledAt(lib$es6$promise$$internal$$REJECTED, i, reason);
479
- });
480
- };
481
431
  function lib$es6$promise$promise$all$$all(entries) {
482
432
  return new lib$es6$promise$enumerator$$default(this, entries).promise;
483
433
  }
@@ -486,43 +436,20 @@
486
436
  /*jshint validthis:true */
487
437
  var Constructor = this;
488
438
 
489
- var promise = new Constructor(lib$es6$promise$$internal$$noop);
490
-
491
439
  if (!lib$es6$promise$utils$$isArray(entries)) {
492
- lib$es6$promise$$internal$$reject(promise, new TypeError('You must pass an array to race.'));
493
- return promise;
494
- }
495
-
496
- var length = entries.length;
497
-
498
- function onFulfillment(value) {
499
- lib$es6$promise$$internal$$resolve(promise, value);
500
- }
501
-
502
- function onRejection(reason) {
503
- lib$es6$promise$$internal$$reject(promise, reason);
504
- }
505
-
506
- for (var i = 0; promise._state === lib$es6$promise$$internal$$PENDING && i < length; i++) {
507
- lib$es6$promise$$internal$$subscribe(Constructor.resolve(entries[i]), undefined, onFulfillment, onRejection);
440
+ return new Constructor(function(resolve, reject) {
441
+ reject(new TypeError('You must pass an array to race.'));
442
+ });
443
+ } else {
444
+ return new Constructor(function(resolve, reject) {
445
+ var length = entries.length;
446
+ for (var i = 0; i < length; i++) {
447
+ Constructor.resolve(entries[i]).then(resolve, reject);
448
+ }
449
+ });
508
450
  }
509
-
510
- return promise;
511
451
  }
512
452
  var lib$es6$promise$promise$race$$default = lib$es6$promise$promise$race$$race;
513
- function lib$es6$promise$promise$resolve$$resolve(object) {
514
- /*jshint validthis:true */
515
- var Constructor = this;
516
-
517
- if (object && typeof object === 'object' && object.constructor === Constructor) {
518
- return object;
519
- }
520
-
521
- var promise = new Constructor(lib$es6$promise$$internal$$noop);
522
- lib$es6$promise$$internal$$resolve(promise, object);
523
- return promise;
524
- }
525
- var lib$es6$promise$promise$resolve$$default = lib$es6$promise$promise$resolve$$resolve;
526
453
  function lib$es6$promise$promise$reject$$reject(reason) {
527
454
  /*jshint validthis:true */
528
455
  var Constructor = this;
@@ -532,7 +459,6 @@
532
459
  }
533
460
  var lib$es6$promise$promise$reject$$default = lib$es6$promise$promise$reject$$reject;
534
461
 
535
- var lib$es6$promise$promise$$counter = 0;
536
462
 
537
463
  function lib$es6$promise$promise$$needsResolver() {
538
464
  throw new TypeError('You must pass a resolver function as the first argument to the promise constructor');
@@ -647,21 +573,13 @@
647
573
  @constructor
648
574
  */
649
575
  function lib$es6$promise$promise$$Promise(resolver) {
650
- this._id = lib$es6$promise$promise$$counter++;
651
- this._state = undefined;
652
- this._result = undefined;
576
+ this[lib$es6$promise$$internal$$PROMISE_ID] = lib$es6$promise$$internal$$nextId();
577
+ this._result = this._state = undefined;
653
578
  this._subscribers = [];
654
579
 
655
580
  if (lib$es6$promise$$internal$$noop !== resolver) {
656
- if (!lib$es6$promise$utils$$isFunction(resolver)) {
657
- lib$es6$promise$promise$$needsResolver();
658
- }
659
-
660
- if (!(this instanceof lib$es6$promise$promise$$Promise)) {
661
- lib$es6$promise$promise$$needsNew();
662
- }
663
-
664
- lib$es6$promise$$internal$$initializePromise(this, resolver);
581
+ typeof resolver !== 'function' && lib$es6$promise$promise$$needsResolver();
582
+ this instanceof lib$es6$promise$promise$$Promise ? lib$es6$promise$$internal$$initializePromise(this, resolver) : lib$es6$promise$promise$$needsNew();
665
583
  }
666
584
  }
667
585
 
@@ -869,28 +787,7 @@
869
787
  Useful for tooling.
870
788
  @return {Promise}
871
789
  */
872
- then: function(onFulfillment, onRejection) {
873
- var parent = this;
874
- var state = parent._state;
875
-
876
- if (state === lib$es6$promise$$internal$$FULFILLED && !onFulfillment || state === lib$es6$promise$$internal$$REJECTED && !onRejection) {
877
- return this;
878
- }
879
-
880
- var child = new this.constructor(lib$es6$promise$$internal$$noop);
881
- var result = parent._result;
882
-
883
- if (state) {
884
- var callback = arguments[state - 1];
885
- lib$es6$promise$asap$$asap(function(){
886
- lib$es6$promise$$internal$$invokeCallback(state, child, callback, result);
887
- });
888
- } else {
889
- lib$es6$promise$$internal$$subscribe(parent, child, onFulfillment, onRejection);
890
- }
891
-
892
- return child;
893
- },
790
+ then: lib$es6$promise$then$$default,
894
791
 
895
792
  /**
896
793
  `catch` is simply sugar for `then(undefined, onRejection)` which makes it the same
@@ -923,6 +820,101 @@
923
820
  return this.then(null, onRejection);
924
821
  }
925
822
  };
823
+ var lib$es6$promise$enumerator$$default = lib$es6$promise$enumerator$$Enumerator;
824
+ function lib$es6$promise$enumerator$$Enumerator(Constructor, input) {
825
+ this._instanceConstructor = Constructor;
826
+ this.promise = new Constructor(lib$es6$promise$$internal$$noop);
827
+
828
+ if (!this.promise[lib$es6$promise$$internal$$PROMISE_ID]) {
829
+ lib$es6$promise$$internal$$makePromise(this.promise);
830
+ }
831
+
832
+ if (Array.isArray(input)) {
833
+ this._input = input;
834
+ this.length = input.length;
835
+ this._remaining = input.length;
836
+
837
+ this._result = new Array(this.length);
838
+
839
+ if (this.length === 0) {
840
+ lib$es6$promise$$internal$$fulfill(this.promise, this._result);
841
+ } else {
842
+ this.length = this.length || 0;
843
+ this._enumerate();
844
+ if (this._remaining === 0) {
845
+ lib$es6$promise$$internal$$fulfill(this.promise, this._result);
846
+ }
847
+ }
848
+ } else {
849
+ lib$es6$promise$$internal$$reject(this.promise, lib$es6$promise$enumerator$$validationError());
850
+ }
851
+ }
852
+
853
+ function lib$es6$promise$enumerator$$validationError() {
854
+ return new Error('Array Methods must be provided an Array');
855
+ }
856
+
857
+ lib$es6$promise$enumerator$$Enumerator.prototype._enumerate = function() {
858
+ var length = this.length;
859
+ var input = this._input;
860
+
861
+ for (var i = 0; this._state === lib$es6$promise$$internal$$PENDING && i < length; i++) {
862
+ this._eachEntry(input[i], i);
863
+ }
864
+ };
865
+
866
+ lib$es6$promise$enumerator$$Enumerator.prototype._eachEntry = function(entry, i) {
867
+ var c = this._instanceConstructor;
868
+ var resolve = c.resolve;
869
+
870
+ if (resolve === lib$es6$promise$promise$resolve$$default) {
871
+ var then = lib$es6$promise$$internal$$getThen(entry);
872
+
873
+ if (then === lib$es6$promise$then$$default &&
874
+ entry._state !== lib$es6$promise$$internal$$PENDING) {
875
+ this._settledAt(entry._state, i, entry._result);
876
+ } else if (typeof then !== 'function') {
877
+ this._remaining--;
878
+ this._result[i] = entry;
879
+ } else if (c === lib$es6$promise$promise$$default) {
880
+ var promise = new c(lib$es6$promise$$internal$$noop);
881
+ lib$es6$promise$$internal$$handleMaybeThenable(promise, entry, then);
882
+ this._willSettleAt(promise, i);
883
+ } else {
884
+ this._willSettleAt(new c(function(resolve) { resolve(entry); }), i);
885
+ }
886
+ } else {
887
+ this._willSettleAt(resolve(entry), i);
888
+ }
889
+ };
890
+
891
+ lib$es6$promise$enumerator$$Enumerator.prototype._settledAt = function(state, i, value) {
892
+ var promise = this.promise;
893
+
894
+ if (promise._state === lib$es6$promise$$internal$$PENDING) {
895
+ this._remaining--;
896
+
897
+ if (state === lib$es6$promise$$internal$$REJECTED) {
898
+ lib$es6$promise$$internal$$reject(promise, value);
899
+ } else {
900
+ this._result[i] = value;
901
+ }
902
+ }
903
+
904
+ if (this._remaining === 0) {
905
+ lib$es6$promise$$internal$$fulfill(promise, this._result);
906
+ }
907
+ };
908
+
909
+ lib$es6$promise$enumerator$$Enumerator.prototype._willSettleAt = function(promise, i) {
910
+ var enumerator = this;
911
+
912
+ lib$es6$promise$$internal$$subscribe(promise, undefined, function(value) {
913
+ enumerator._settledAt(lib$es6$promise$$internal$$FULFILLED, i, value);
914
+ }, function(reason) {
915
+ enumerator._settledAt(lib$es6$promise$$internal$$REJECTED, i, reason);
916
+ });
917
+ };
926
918
  function lib$es6$promise$polyfill$$polyfill() {
927
919
  var local;
928
920
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: es6-promise-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.2
4
+ version: 3.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Leonid Beder
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-10-07 00:00:00.000000000 Z
11
+ date: 2016-04-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties
@@ -60,9 +60,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
60
60
  version: '0'
61
61
  requirements: []
62
62
  rubyforge_project:
63
- rubygems_version: 2.4.8
63
+ rubygems_version: 2.4.6
64
64
  signing_key:
65
65
  specification_version: 4
66
66
  summary: A polyfill for ES6-style Promises with integration for Rails
67
67
  test_files: []
68
- has_rdoc: