ember-source 2.16.1 → 2.16.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 32904c39bf4645df84aaa32684719aca56947dfb
4
- data.tar.gz: 45044a3f4272492ae8542a926e2418abea44518f
3
+ metadata.gz: 3cae6aadab3a9b1f89304fc6ac6790e785131d5c
4
+ data.tar.gz: cb65a1ac3894e4b4b95a6c87c9a96bbcffa4d49a
5
5
  SHA512:
6
- metadata.gz: d392ac2f69a378a36ce85475a41dcff567a796e975df5c8a340ef4d43b498d78d93daa1cc11e5db118c8e1aa68d6ccb67dd387260ce00973c31b43ce0334e24d
7
- data.tar.gz: 8b4231fbecf3a1b99c3ec9070881c4ce35dea2821eb6a8eb37943172f38d22a953b5be47813d4383872577a78c3aba49bcdd875daa0f2108226b48c94e469004
6
+ metadata.gz: 64632d3193ec7c79e042309d1d8ac04998d448365bbffa6fe78a756598854502d8a79369ca9366ed9ca8a0684aa26cd6ff3a3f6d76ea8df4ca31feb790dfdc66
7
+ data.tar.gz: 95f80c4940c73cce104fceb0ddbbfc44a7550530fd2458185e5ba09188d720799f0a4b5bae2e8b284146fb617bae6b968549a0a1dba4ab97771a628c9dac15f5
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.16.1
1
+ 2.16.2
@@ -6,7 +6,7 @@
6
6
  * Portions Copyright 2008-2011 Apple Inc. All rights reserved.
7
7
  * @license Licensed under MIT license
8
8
  * See https://raw.github.com/emberjs/ember.js/master/LICENSE
9
- * @version 2.16.1
9
+ * @version 2.16.2
10
10
  */
11
11
 
12
12
  var enifed, requireModule, Ember;
@@ -8776,16 +8776,6 @@ enifed('rsvp', ['exports', 'ember-babel', 'node-module'], function (exports, _em
8776
8776
 
8777
8777
  var _rsvp;
8778
8778
 
8779
- function indexOf(callbacks, callback) {
8780
- for (var i = 0, l = callbacks.length; i < l; i++) {
8781
- if (callbacks[i] === callback) {
8782
- return i;
8783
- }
8784
- }
8785
-
8786
- return -1;
8787
- }
8788
-
8789
8779
  function callbacksFor(object) {
8790
8780
  var callbacks = object._promiseCallbacks;
8791
8781
 
@@ -8821,7 +8811,7 @@ enifed('rsvp', ['exports', 'ember-babel', 'node-module'], function (exports, _em
8821
8811
  callbacks = allCallbacks[eventName] = [];
8822
8812
  }
8823
8813
 
8824
- if (indexOf(callbacks, callback) === -1) {
8814
+ if (callbacks.indexOf(callback)) {
8825
8815
  callbacks.push(callback);
8826
8816
  }
8827
8817
  },
@@ -8837,7 +8827,7 @@ enifed('rsvp', ['exports', 'ember-babel', 'node-module'], function (exports, _em
8837
8827
 
8838
8828
  callbacks = allCallbacks[eventName];
8839
8829
 
8840
- index = indexOf(callbacks, callback);
8830
+ index = callbacks.indexOf(callback);
8841
8831
 
8842
8832
  if (index !== -1) {
8843
8833
  callbacks.splice(index, 1);
@@ -8873,40 +8863,6 @@ enifed('rsvp', ['exports', 'ember-babel', 'node-module'], function (exports, _em
8873
8863
  }
8874
8864
  }
8875
8865
 
8876
- function objectOrFunction(x) {
8877
- var type = typeof x;
8878
- return x !== null && (type === 'object' || type === 'function');
8879
- }
8880
-
8881
- function isFunction(x) {
8882
- return typeof x === 'function';
8883
- }
8884
-
8885
- function isObject(x) {
8886
- return x !== null && typeof x === 'object';
8887
- }
8888
-
8889
- function isMaybeThenable(x) {
8890
- return x !== null && typeof x === 'object';
8891
- }
8892
-
8893
- var _isArray = void 0;
8894
- if (Array.isArray) {
8895
- _isArray = Array.isArray;
8896
- } else {
8897
- _isArray = function (x) {
8898
- return Object.prototype.toString.call(x) === '[object Array]';
8899
- };
8900
- }
8901
-
8902
- var isArray = _isArray;
8903
-
8904
- // Date.now is not available in browsers < IE9
8905
- // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/now#Compatibility
8906
- var now = Date.now || function () {
8907
- return new Date().getTime();
8908
- };
8909
-
8910
8866
  var queue = [];
8911
8867
 
8912
8868
  function scheduleFlush() {
@@ -8938,7 +8894,7 @@ enifed('rsvp', ['exports', 'ember-babel', 'node-module'], function (exports, _em
8938
8894
  detail: promise._result,
8939
8895
  childId: child && child._id,
8940
8896
  label: promise._label,
8941
- timeStamp: now(),
8897
+ timeStamp: Date.now(),
8942
8898
  error: config["instrument-with-stack"] ? new Error(promise._label) : null
8943
8899
  } })) {
8944
8900
  scheduleFlush();
@@ -8994,12 +8950,21 @@ enifed('rsvp', ['exports', 'ember-babel', 'node-module'], function (exports, _em
8994
8950
  return new TypeError('A promises callback cannot return that same promise.');
8995
8951
  }
8996
8952
 
8953
+ function objectOrFunction(x) {
8954
+ var type = typeof x;
8955
+ return x !== null && (type === 'object' || type === 'function');
8956
+ }
8957
+
8997
8958
  function noop() {}
8998
8959
 
8999
8960
  var PENDING = void 0;
9000
8961
  var FULFILLED = 1;
9001
8962
  var REJECTED = 2;
9002
8963
 
8964
+ function ErrorObject() {
8965
+ this.error = null;
8966
+ }
8967
+
9003
8968
  var GET_THEN_ERROR = new ErrorObject();
9004
8969
 
9005
8970
  function getThen(promise) {
@@ -9011,6 +8976,25 @@ enifed('rsvp', ['exports', 'ember-babel', 'node-module'], function (exports, _em
9011
8976
  }
9012
8977
  }
9013
8978
 
8979
+ var TRY_CATCH_ERROR = new ErrorObject();
8980
+
8981
+ var tryCatchCallback = void 0;
8982
+ function tryCatcher() {
8983
+ try {
8984
+ var target = tryCatchCallback;
8985
+ tryCatchCallback = null;
8986
+ return target.apply(this, arguments);
8987
+ } catch (e) {
8988
+ TRY_CATCH_ERROR.error = e;
8989
+ return TRY_CATCH_ERROR;
8990
+ }
8991
+ }
8992
+
8993
+ function tryCatch(fn) {
8994
+ tryCatchCallback = fn;
8995
+ return tryCatcher;
8996
+ }
8997
+
9014
8998
  function tryThen(then$$1, value, fulfillmentHandler, rejectionHandler) {
9015
8999
  try {
9016
9000
  then$$1.call(value, fulfillmentHandler, rejectionHandler);
@@ -9056,10 +9040,10 @@ enifed('rsvp', ['exports', 'ember-babel', 'node-module'], function (exports, _em
9056
9040
  reject(promise, thenable._result);
9057
9041
  } else {
9058
9042
  subscribe(thenable, undefined, function (value) {
9059
- if (thenable !== value) {
9060
- resolve(promise, value, undefined);
9061
- } else {
9043
+ if (thenable === value) {
9062
9044
  fulfill(promise, value);
9045
+ } else {
9046
+ resolve(promise, value);
9063
9047
  }
9064
9048
  }, function (reason) {
9065
9049
  return reject(promise, reason);
@@ -9073,9 +9057,10 @@ enifed('rsvp', ['exports', 'ember-babel', 'node-module'], function (exports, _em
9073
9057
  if (isOwnThenable) {
9074
9058
  handleOwnThenable(promise, maybeThenable);
9075
9059
  } else if (then$$1 === GET_THEN_ERROR) {
9076
- reject(promise, GET_THEN_ERROR.error);
9060
+ var error = GET_THEN_ERROR.error;
9077
9061
  GET_THEN_ERROR.error = null;
9078
- } else if (isFunction(then$$1)) {
9062
+ reject(promise, error);
9063
+ } else if (typeof then$$1 === 'function') {
9079
9064
  handleForeignThenable(promise, maybeThenable, then$$1);
9080
9065
  } else {
9081
9066
  fulfill(promise, maybeThenable);
@@ -9171,46 +9156,26 @@ enifed('rsvp', ['exports', 'ember-babel', 'node-module'], function (exports, _em
9171
9156
  promise._subscribers.length = 0;
9172
9157
  }
9173
9158
 
9174
- function ErrorObject() {
9175
- this.error = null;
9176
- }
9177
-
9178
- var TRY_CATCH_ERROR = new ErrorObject();
9179
-
9180
- function tryCatch(callback, result) {
9181
- try {
9182
- return callback(result);
9183
- } catch (e) {
9184
- TRY_CATCH_ERROR.error = e;
9185
- return TRY_CATCH_ERROR;
9186
- }
9187
- }
9188
-
9189
9159
  function invokeCallback(state, promise, callback, result) {
9190
- var hasCallback = isFunction(callback);
9191
- var value = void 0,
9192
- error = void 0;
9160
+ var hasCallback = typeof callback === 'function';
9161
+ var value = void 0;
9193
9162
 
9194
9163
  if (hasCallback) {
9195
- value = tryCatch(callback, result);
9196
-
9197
- if (value === TRY_CATCH_ERROR) {
9198
- error = value.error;
9199
- value.error = null; // release
9200
- } else if (value === promise) {
9201
- reject(promise, withOwnPromise());
9202
- return;
9203
- }
9164
+ value = tryCatch(callback)(result);
9204
9165
  } else {
9205
9166
  value = result;
9206
9167
  }
9207
9168
 
9208
9169
  if (promise._state !== PENDING) {
9209
9170
  // noop
9210
- } else if (hasCallback && error === undefined) {
9211
- resolve(promise, value);
9212
- } else if (error !== undefined) {
9171
+ } else if (value === promise) {
9172
+ reject(promise, withOwnPromise());
9173
+ } else if (value === TRY_CATCH_ERROR) {
9174
+ var error = value.error;
9175
+ value.error = null; // release
9213
9176
  reject(promise, error);
9177
+ } else if (hasCallback) {
9178
+ resolve(promise, value);
9214
9179
  } else if (state === FULFILLED) {
9215
9180
  fulfill(promise, value);
9216
9181
  } else if (state === REJECTED) {
@@ -9267,109 +9232,118 @@ enifed('rsvp', ['exports', 'ember-babel', 'node-module'], function (exports, _em
9267
9232
  return child;
9268
9233
  }
9269
9234
 
9270
- function Enumerator(Constructor, input, abortOnReject, label) {
9271
- this._instanceConstructor = Constructor;
9272
- this.promise = new Constructor(noop, label);
9273
- this._abortOnReject = abortOnReject;
9235
+ var Enumerator = function () {
9236
+ function Enumerator(Constructor, input, abortOnReject, label) {
9237
+ (0, _emberBabel.classCallCheck)(this, Enumerator);
9274
9238
 
9275
- this._init.apply(this, arguments);
9276
- }
9239
+ this._instanceConstructor = Constructor;
9240
+ this.promise = new Constructor(noop, label);
9241
+ this._abortOnReject = abortOnReject;
9242
+ this.isUsingOwnPromise = Constructor === Promise;
9277
9243
 
9278
- Enumerator.prototype._init = function (Constructor, input) {
9279
- var len = input.length || 0;
9280
- this.length = len;
9281
- this._remaining = len;
9282
- this._result = new Array(len);
9283
-
9284
- this._enumerate(input);
9285
- if (this._remaining === 0) {
9286
- fulfill(this.promise, this._result);
9244
+ this._init.apply(this, arguments);
9287
9245
  }
9288
- };
9289
9246
 
9290
- Enumerator.prototype._enumerate = function (input) {
9291
- var length = this.length;
9292
- var promise = this.promise;
9247
+ Enumerator.prototype._init = function _init(Constructor, input) {
9248
+ var len = input.length || 0;
9249
+ this.length = len;
9250
+ this._remaining = len;
9251
+ this._result = new Array(len);
9293
9252
 
9294
- for (var i = 0; promise._state === PENDING && i < length; i++) {
9295
- this._eachEntry(input[i], i);
9296
- }
9297
- };
9253
+ this._enumerate(input);
9254
+ };
9255
+
9256
+ Enumerator.prototype._enumerate = function _enumerate(input) {
9257
+ var length = this.length;
9258
+ var promise = this.promise;
9298
9259
 
9299
- Enumerator.prototype._settleMaybeThenable = function (entry, i) {
9300
- var c = this._instanceConstructor;
9301
- var resolve$$1 = c.resolve;
9260
+ for (var i = 0; promise._state === PENDING && i < length; i++) {
9261
+ this._eachEntry(input[i], i, true);
9262
+ }
9302
9263
 
9303
- if (resolve$$1 === resolve$1) {
9304
- var then$$1 = getThen(entry);
9264
+ this._checkFullfillment();
9265
+ };
9305
9266
 
9306
- if (then$$1 === then && entry._state !== PENDING) {
9307
- entry._onError = null;
9308
- this._settledAt(entry._state, i, entry._result);
9309
- } else if (typeof then$$1 !== 'function') {
9310
- this._remaining--;
9311
- this._result[i] = this._makeResult(FULFILLED, i, entry);
9312
- } else if (c === Promise) {
9313
- var promise = new c(noop);
9314
- handleMaybeThenable(promise, entry, then$$1);
9315
- this._willSettleAt(promise, i);
9316
- } else {
9317
- this._willSettleAt(new c(function (resolve$$1) {
9318
- return resolve$$1(entry);
9319
- }), i);
9267
+ Enumerator.prototype._checkFullfillment = function _checkFullfillment() {
9268
+ if (this._remaining === 0) {
9269
+ fulfill(this.promise, this._result);
9320
9270
  }
9321
- } else {
9322
- this._willSettleAt(resolve$$1(entry), i);
9323
- }
9324
- };
9271
+ };
9325
9272
 
9326
- Enumerator.prototype._eachEntry = function (entry, i) {
9327
- if (isMaybeThenable(entry)) {
9328
- this._settleMaybeThenable(entry, i);
9329
- } else {
9330
- this._remaining--;
9331
- this._result[i] = this._makeResult(FULFILLED, i, entry);
9332
- }
9333
- };
9273
+ Enumerator.prototype._settleMaybeThenable = function _settleMaybeThenable(entry, i, firstPass) {
9274
+ var c = this._instanceConstructor;
9275
+ var resolve$$1 = c.resolve;
9334
9276
 
9335
- Enumerator.prototype._settledAt = function (state, i, value) {
9336
- var promise = this.promise;
9277
+ if (resolve$$1 === resolve$1) {
9278
+ var then$$1 = getThen(entry);
9337
9279
 
9338
- if (promise._state === PENDING) {
9339
- if (this._abortOnReject && state === REJECTED) {
9340
- reject(promise, value);
9280
+ if (then$$1 === then && entry._state !== PENDING) {
9281
+ entry._onError = null;
9282
+ this._settledAt(entry._state, i, entry._result, firstPass);
9283
+ } else if (typeof then$$1 !== 'function') {
9284
+ this._settledAt(FULFILLED, i, entry, firstPass);
9285
+ } else if (this.isUsingOwnPromise) {
9286
+ var promise = new c(noop);
9287
+ handleMaybeThenable(promise, entry, then$$1);
9288
+ this._willSettleAt(promise, i, firstPass);
9289
+ } else {
9290
+ this._willSettleAt(new c(function (resolve$$1) {
9291
+ return resolve$$1(entry);
9292
+ }), i, firstPass);
9293
+ }
9341
9294
  } else {
9342
- this._remaining--;
9343
- this._result[i] = this._makeResult(state, i, value);
9344
- if (this._remaining === 0) {
9345
- fulfill(promise, this._result);
9295
+ this._willSettleAt(resolve$$1(entry), i, firstPass);
9296
+ }
9297
+ };
9298
+
9299
+ Enumerator.prototype._eachEntry = function _eachEntry(entry, i, firstPass) {
9300
+ if (entry !== null && typeof entry === 'object') {
9301
+ this._settleMaybeThenable(entry, i, firstPass);
9302
+ } else {
9303
+ this._setResultAt(FULFILLED, i, entry, firstPass);
9304
+ }
9305
+ };
9306
+
9307
+ Enumerator.prototype._settledAt = function _settledAt(state, i, value, firstPass) {
9308
+ var promise = this.promise;
9309
+
9310
+ if (promise._state === PENDING) {
9311
+ if (this._abortOnReject && state === REJECTED) {
9312
+ reject(promise, value);
9313
+ } else {
9314
+ this._setResultAt(state, i, value, firstPass);
9315
+ this._checkFullfillment();
9346
9316
  }
9347
9317
  }
9348
- }
9349
- };
9318
+ };
9350
9319
 
9351
- Enumerator.prototype._makeResult = function (state, i, value) {
9352
- return value;
9353
- };
9320
+ Enumerator.prototype._setResultAt = function _setResultAt(state, i, value, firstPass) {
9321
+ this._remaining--;
9322
+ this._result[i] = value;
9323
+ };
9354
9324
 
9355
- Enumerator.prototype._willSettleAt = function (promise, i) {
9356
- var enumerator = this;
9325
+ Enumerator.prototype._willSettleAt = function _willSettleAt(promise, i, firstPass) {
9326
+ var _this = this;
9357
9327
 
9358
- subscribe(promise, undefined, function (value) {
9359
- return enumerator._settledAt(FULFILLED, i, value);
9360
- }, function (reason) {
9361
- return enumerator._settledAt(REJECTED, i, reason);
9362
- });
9363
- };
9328
+ subscribe(promise, undefined, function (value) {
9329
+ return _this._settledAt(FULFILLED, i, value, firstPass);
9330
+ }, function (reason) {
9331
+ return _this._settledAt(REJECTED, i, reason, firstPass);
9332
+ });
9333
+ };
9364
9334
 
9365
- function makeSettledResult(state, position, value) {
9335
+ return Enumerator;
9336
+ }();
9337
+
9338
+ function setSettledResult(state, i, value) {
9339
+ this._remaining--;
9366
9340
  if (state === FULFILLED) {
9367
- return {
9341
+ this._result[i] = {
9368
9342
  state: 'fulfilled',
9369
9343
  value: value
9370
9344
  };
9371
9345
  } else {
9372
- return {
9346
+ this._result[i] = {
9373
9347
  state: 'rejected',
9374
9348
  reason: value
9375
9349
  };
@@ -9424,7 +9398,7 @@ enifed('rsvp', ['exports', 'ember-babel', 'node-module'], function (exports, _em
9424
9398
  @static
9425
9399
  */
9426
9400
  function all(entries, label) {
9427
- if (!isArray(entries)) {
9401
+ if (!Array.isArray(entries)) {
9428
9402
  return this.reject(new TypeError("Promise.all must be called with an array"), label);
9429
9403
  }
9430
9404
  return new Enumerator(this, entries, true /* abort on reject */, label).promise;
@@ -9502,7 +9476,7 @@ enifed('rsvp', ['exports', 'ember-babel', 'node-module'], function (exports, _em
9502
9476
 
9503
9477
  var promise = new Constructor(noop, label);
9504
9478
 
9505
- if (!isArray(entries)) {
9479
+ if (!Array.isArray(entries)) {
9506
9480
  reject(promise, new TypeError('Promise.race must be called with an array'));
9507
9481
  return promise;
9508
9482
  }
@@ -9561,7 +9535,7 @@ enifed('rsvp', ['exports', 'ember-babel', 'node-module'], function (exports, _em
9561
9535
  return promise;
9562
9536
  }
9563
9537
 
9564
- var guidKey = 'rsvp_' + now() + '-';
9538
+ var guidKey = 'rsvp_' + Date.now() + '-';
9565
9539
  var counter = 0;
9566
9540
 
9567
9541
  function needsResolver() {
@@ -9676,117 +9650,56 @@ enifed('rsvp', ['exports', 'ember-babel', 'node-module'], function (exports, _em
9676
9650
  Useful for tooling.
9677
9651
  @constructor
9678
9652
  */
9679
- function Promise(resolver, label) {
9680
- this._id = counter++;
9681
- this._label = label;
9682
- this._state = undefined;
9683
- this._result = undefined;
9684
- this._subscribers = [];
9685
9653
 
9686
- config.instrument && instrument('created', this);
9654
+ var Promise = function () {
9655
+ function Promise(resolver, label) {
9656
+ (0, _emberBabel.classCallCheck)(this, Promise);
9687
9657
 
9688
- if (noop !== resolver) {
9689
- typeof resolver !== 'function' && needsResolver();
9690
- this instanceof Promise ? initializePromise(this, resolver) : needsNew();
9691
- }
9692
- }
9658
+ this._id = counter++;
9659
+ this._label = label;
9660
+ this._state = undefined;
9661
+ this._result = undefined;
9662
+ this._subscribers = [];
9693
9663
 
9694
- Promise.prototype._onError = function (reason) {
9695
- var _this = this;
9664
+ config.instrument && instrument('created', this);
9696
9665
 
9697
- config.after(function () {
9698
- if (_this._onError) {
9699
- config.trigger('error', reason, _this._label);
9666
+ if (noop !== resolver) {
9667
+ typeof resolver !== 'function' && needsResolver();
9668
+ this instanceof Promise ? initializePromise(this, resolver) : needsNew();
9700
9669
  }
9701
- });
9702
- };
9703
-
9704
- /**
9705
- `catch` is simply sugar for `then(undefined, onRejection)` which makes it the same
9706
- as the catch block of a try/catch statement.
9707
-
9708
- ```js
9709
- function findAuthor(){
9710
- throw new Error('couldn\'t find that author');
9711
9670
  }
9712
-
9713
- // synchronous
9714
- try {
9715
- findAuthor();
9716
- } catch(reason) {
9717
- // something went wrong
9718
- }
9719
-
9720
- // async with promises
9721
- findAuthor().catch(function(reason){
9722
- // something went wrong
9723
- });
9724
- ```
9725
-
9726
- @method catch
9727
- @param {Function} onRejection
9728
- @param {String} label optional string for labeling the promise.
9729
- Useful for tooling.
9730
- @return {Promise}
9731
- */
9732
- Promise.prototype.catch = function (onRejection, label) {
9733
- return this.then(undefined, onRejection, label);
9734
- };
9735
9671
 
9736
- /**
9737
- `finally` will be invoked regardless of the promise's fate just as native
9738
- try/catch/finally behaves
9739
-
9740
- Synchronous example:
9741
-
9742
- ```js
9743
- findAuthor() {
9744
- if (Math.random() > 0.5) {
9745
- throw new Error();
9746
- }
9747
- return new Author();
9748
- }
9749
-
9750
- try {
9751
- return findAuthor(); // succeed or fail
9752
- } catch(error) {
9753
- return findOtherAuthor();
9754
- } finally {
9755
- // always runs
9756
- // doesn't affect the return value
9757
- }
9758
- ```
9759
-
9760
- Asynchronous example:
9761
-
9762
- ```js
9763
- findAuthor().catch(function(reason){
9764
- return findOtherAuthor();
9765
- }).finally(function(){
9766
- // author was either found, or not
9767
- });
9768
- ```
9769
-
9770
- @method finally
9771
- @param {Function} callback
9772
- @param {String} label optional string for labeling the promise.
9773
- Useful for tooling.
9774
- @return {Promise}
9775
- */
9776
- Promise.prototype.finally = function (callback, label) {
9777
- var promise = this;
9778
- var constructor = promise.constructor;
9672
+ Promise.prototype._onError = function _onError(reason) {
9673
+ var _this2 = this;
9779
9674
 
9780
- return promise.then(function (value) {
9781
- return constructor.resolve(callback()).then(function () {
9782
- return value;
9783
- });
9784
- }, function (reason) {
9785
- return constructor.resolve(callback()).then(function () {
9786
- throw reason;
9675
+ config.after(function () {
9676
+ if (_this2._onError) {
9677
+ config.trigger('error', reason, _this2._label);
9678
+ }
9787
9679
  });
9788
- }, label);
9789
- };
9680
+ };
9681
+
9682
+ Promise.prototype.catch = function _catch(onRejection, label) {
9683
+ return this.then(undefined, onRejection, label);
9684
+ };
9685
+
9686
+ Promise.prototype.finally = function _finally(callback, label) {
9687
+ var promise = this;
9688
+ var constructor = promise.constructor;
9689
+
9690
+ return promise.then(function (value) {
9691
+ return constructor.resolve(callback()).then(function () {
9692
+ return value;
9693
+ });
9694
+ }, function (reason) {
9695
+ return constructor.resolve(callback()).then(function () {
9696
+ throw reason;
9697
+ });
9698
+ }, label);
9699
+ };
9700
+
9701
+ return Promise;
9702
+ }();
9790
9703
 
9791
9704
  Promise.cast = resolve$1; // deprecated
9792
9705
  Promise.all = all;
@@ -10208,7 +10121,7 @@ enifed('rsvp', ['exports', 'ember-babel', 'node-module'], function (exports, _em
10208
10121
  var promise = new Promise(noop);
10209
10122
 
10210
10123
  args[l] = function (err, val) {
10211
- if (err) reject(promise, err);else if (options === undefined) resolve(promise, val);else if (options === true) resolve(promise, arrayResult(arguments));else if (isArray(options)) resolve(promise, makeObject(arguments, options));else resolve(promise, val);
10124
+ if (err) reject(promise, err);else if (options === undefined) resolve(promise, val);else if (options === true) resolve(promise, arrayResult(arguments));else if (Array.isArray(options)) resolve(promise, makeObject(arguments, options));else resolve(promise, val);
10212
10125
  };
10213
10126
 
10214
10127
  if (promiseInput) {
@@ -10279,7 +10192,7 @@ enifed('rsvp', ['exports', 'ember-babel', 'node-module'], function (exports, _em
10279
10192
  return AllSettled;
10280
10193
  }(Enumerator);
10281
10194
 
10282
- AllSettled.prototype._makeResult = makeSettledResult;
10195
+ AllSettled.prototype._setResultAt = setSettledResult;
10283
10196
 
10284
10197
  /**
10285
10198
  `RSVP.allSettled` is similar to `RSVP.all`, but instead of implementing
@@ -10327,7 +10240,7 @@ enifed('rsvp', ['exports', 'ember-babel', 'node-module'], function (exports, _em
10327
10240
  */
10328
10241
 
10329
10242
  function allSettled(entries, label) {
10330
- if (!isArray(entries)) {
10243
+ if (!Array.isArray(entries)) {
10331
10244
  return Promise.reject(new TypeError("Promise.allSettled must be called with an array"), label);
10332
10245
  }
10333
10246
 
@@ -10484,7 +10397,7 @@ enifed('rsvp', ['exports', 'ember-babel', 'node-module'], function (exports, _em
10484
10397
  have been fulfilled, or rejected if any of them become rejected.
10485
10398
  */
10486
10399
  function hash(object, label) {
10487
- if (!isObject(object)) {
10400
+ if (object === null || typeof object !== 'object') {
10488
10401
  return Promise.reject(new TypeError("Promise.hash must be called with an object"), label);
10489
10402
  }
10490
10403
 
@@ -10502,7 +10415,7 @@ enifed('rsvp', ['exports', 'ember-babel', 'node-module'], function (exports, _em
10502
10415
  return HashSettled;
10503
10416
  }(PromiseHash);
10504
10417
 
10505
- HashSettled.prototype._makeResult = makeSettledResult;
10418
+ HashSettled.prototype._setResultAt = setSettledResult;
10506
10419
 
10507
10420
  /**
10508
10421
  `RSVP.hashSettled` is similar to `RSVP.allSettled`, but takes an object
@@ -10607,7 +10520,7 @@ enifed('rsvp', ['exports', 'ember-babel', 'node-module'], function (exports, _em
10607
10520
  */
10608
10521
 
10609
10522
  function hashSettled(object, label) {
10610
- if (!isObject(object)) {
10523
+ if (object === null || typeof object !== 'object') {
10611
10524
  return Promise.reject(new TypeError("RSVP.hashSettled must be called with an object"), label);
10612
10525
  }
10613
10526
 
@@ -10705,12 +10618,46 @@ enifed('rsvp', ['exports', 'ember-babel', 'node-module'], function (exports, _em
10705
10618
  return deferred;
10706
10619
  }
10707
10620
 
10621
+ var MapEnumerator = function (_Enumerator3) {
10622
+ (0, _emberBabel.inherits)(MapEnumerator, _Enumerator3);
10623
+
10624
+ function MapEnumerator(Constructor, entries, mapFn, label) {
10625
+ (0, _emberBabel.classCallCheck)(this, MapEnumerator);
10626
+ return (0, _emberBabel.possibleConstructorReturn)(this, _Enumerator3.call(this, Constructor, entries, true, label, mapFn));
10627
+ }
10628
+
10629
+ MapEnumerator.prototype._init = function _init(Constructor, input, bool, label, mapFn) {
10630
+ var len = input.length || 0;
10631
+ this.length = len;
10632
+ this._remaining = len;
10633
+ this._result = new Array(len);
10634
+ this._mapFn = mapFn;
10635
+
10636
+ this._enumerate(input);
10637
+ };
10638
+
10639
+ MapEnumerator.prototype._setResultAt = function _setResultAt(state, i, value, firstPass) {
10640
+ if (firstPass) {
10641
+ var val = tryCatch(this._mapFn)(value, i);
10642
+ if (val === TRY_CATCH_ERROR) {
10643
+ this._settledAt(REJECTED, i, val.error, false);
10644
+ } else {
10645
+ this._eachEntry(val, i, false);
10646
+ }
10647
+ } else {
10648
+ this._remaining--;
10649
+ this._result[i] = value;
10650
+ }
10651
+ };
10652
+
10653
+ return MapEnumerator;
10654
+ }(Enumerator);
10655
+
10708
10656
  /**
10709
- `RSVP.map` is similar to JavaScript's native `map` method, except that it
10710
- waits for all promises to become fulfilled before running the `mapFn` on
10711
- each item in given to `promises`. `RSVP.map` returns a promise that will
10712
- become fulfilled with the result of running `mapFn` on the values the promises
10713
- become fulfilled with.
10657
+ `RSVP.map` is similar to JavaScript's native `map` method. `mapFn` is eagerly called
10658
+ meaning that as soon as any promise resolves its value will be passed to `mapFn`.
10659
+ `RSVP.map` returns a promise that will become fulfilled with the result of running
10660
+ `mapFn` on the values the promises become fulfilled with.
10714
10661
 
10715
10662
  For example:
10716
10663
 
@@ -10784,24 +10731,15 @@ enifed('rsvp', ['exports', 'ember-babel', 'node-module'], function (exports, _em
10784
10731
  @static
10785
10732
  */
10786
10733
  function map(promises, mapFn, label) {
10787
- if (!isArray(promises)) {
10734
+ if (!Array.isArray(promises)) {
10788
10735
  return Promise.reject(new TypeError("RSVP.map must be called with an array"), label);
10789
10736
  }
10790
10737
 
10791
- if (!isFunction(mapFn)) {
10738
+ if (typeof mapFn !== 'function') {
10792
10739
  return Promise.reject(new TypeError("RSVP.map expects a function as a second argument"), label);
10793
10740
  }
10794
10741
 
10795
- return Promise.all(promises, label).then(function (values) {
10796
- var length = values.length;
10797
- var results = new Array(length);
10798
-
10799
- for (var i = 0; i < length; i++) {
10800
- results[i] = mapFn(values[i]);
10801
- }
10802
-
10803
- return Promise.all(results, label);
10804
- });
10742
+ return new MapEnumerator(Promise, promises, mapFn, label).promise;
10805
10743
  }
10806
10744
 
10807
10745
  /**
@@ -10835,12 +10773,62 @@ enifed('rsvp', ['exports', 'ember-babel', 'node-module'], function (exports, _em
10835
10773
  return Promise.reject(reason, label);
10836
10774
  }
10837
10775
 
10776
+ var EMPTY_OBJECT = {};
10777
+
10778
+ var FilterEnumerator = function (_Enumerator4) {
10779
+ (0, _emberBabel.inherits)(FilterEnumerator, _Enumerator4);
10780
+
10781
+ function FilterEnumerator(Constructor, entries, filterFn, label) {
10782
+ (0, _emberBabel.classCallCheck)(this, FilterEnumerator);
10783
+ return (0, _emberBabel.possibleConstructorReturn)(this, _Enumerator4.call(this, Constructor, entries, true, label, filterFn));
10784
+ }
10785
+
10786
+ FilterEnumerator.prototype._init = function _init(Constructor, input, bool, label, filterFn) {
10787
+ var len = input.length || 0;
10788
+ this.length = len;
10789
+ this._remaining = len;
10790
+
10791
+ this._result = new Array(len);
10792
+ this._filterFn = filterFn;
10793
+
10794
+ this._enumerate(input);
10795
+ };
10796
+
10797
+ FilterEnumerator.prototype._checkFullfillment = function _checkFullfillment() {
10798
+ if (this._remaining === 0) {
10799
+ this._result = this._result.filter(function (val) {
10800
+ return val !== EMPTY_OBJECT;
10801
+ });
10802
+ fulfill(this.promise, this._result);
10803
+ }
10804
+ };
10805
+
10806
+ FilterEnumerator.prototype._setResultAt = function _setResultAt(state, i, value, firstPass) {
10807
+ if (firstPass) {
10808
+ this._result[i] = value;
10809
+ var val = tryCatch(this._filterFn)(value, i);
10810
+ if (val === TRY_CATCH_ERROR) {
10811
+ this._settledAt(REJECTED, i, val.error, false);
10812
+ } else {
10813
+ this._eachEntry(val, i, false);
10814
+ }
10815
+ } else {
10816
+ this._remaining--;
10817
+ if (!value) {
10818
+ this._result[i] = EMPTY_OBJECT;
10819
+ }
10820
+ }
10821
+ };
10822
+
10823
+ return FilterEnumerator;
10824
+ }(Enumerator);
10825
+
10838
10826
  /**
10839
- `RSVP.filter` is similar to JavaScript's native `filter` method, except that it
10840
- waits for all promises to become fulfilled before running the `filterFn` on
10841
- each item in given to `promises`. `RSVP.filter` returns a promise that will
10842
- become fulfilled with the result of running `filterFn` on the values the
10843
- promises become fulfilled with.
10827
+ `RSVP.filter` is similar to JavaScript's native `filter` method.
10828
+ `filterFn` is eagerly called meaning that as soon as any promise
10829
+ resolves its value will be passed to `filterFn`. `RSVP.filter` returns
10830
+ a promise that will become fulfilled with the result of running
10831
+ `filterFn` on the values the promises become fulfilled with.
10844
10832
 
10845
10833
  For example:
10846
10834
 
@@ -10921,49 +10909,17 @@ enifed('rsvp', ['exports', 'ember-babel', 'node-module'], function (exports, _em
10921
10909
  @return {Promise}
10922
10910
  */
10923
10911
 
10924
- function resolveAll(promises, label) {
10925
- return Promise.all(promises, label);
10926
- }
10927
-
10928
- function resolveSingle(promise, label) {
10929
- return Promise.resolve(promise, label).then(function (promises) {
10930
- return resolveAll(promises, label);
10931
- });
10932
- }
10933
-
10934
10912
  function filter(promises, filterFn, label) {
10935
- if (!isArray(promises) && !(isObject(promises) && promises.then !== undefined)) {
10913
+ if (!Array.isArray(promises) && !(promises !== null && typeof promises === 'object' && promises.then !== undefined)) {
10936
10914
  return Promise.reject(new TypeError("RSVP.filter must be called with an array or promise"), label);
10937
10915
  }
10938
10916
 
10939
- if (!isFunction(filterFn)) {
10917
+ if (typeof filterFn !== 'function') {
10940
10918
  return Promise.reject(new TypeError("RSVP.filter expects function as a second argument"), label);
10941
10919
  }
10942
10920
 
10943
- var promise = isArray(promises) ? resolveAll(promises, label) : resolveSingle(promises, label);
10944
- return promise.then(function (values) {
10945
- var length = values.length;
10946
- var filtered = new Array(length);
10947
-
10948
- for (var i = 0; i < length; i++) {
10949
- filtered[i] = filterFn(values[i]);
10950
- }
10951
-
10952
- return resolveAll(filtered, label).then(function (filtered) {
10953
- var results = new Array(length);
10954
- var newLength = 0;
10955
-
10956
- for (var _i = 0; _i < length; _i++) {
10957
- if (filtered[_i]) {
10958
- results[newLength] = values[_i];
10959
- newLength++;
10960
- }
10961
- }
10962
-
10963
- results.length = newLength;
10964
-
10965
- return results;
10966
- });
10921
+ return Promise.resolve(promises, label).then(function (promises) {
10922
+ return new FilterEnumerator(Promise, promises, filterFn, label).promise;
10967
10923
  });
10968
10924
  }
10969
10925