dist/ember.prod.js in ember-source-2.15.0.beta.1 vs dist/ember.prod.js in ember-source-2.15.0.beta.2
- old
+ new
@@ -4,11 +4,11 @@
* @copyright Copyright 2011-2017 Tilde Inc. and contributors
* Portions Copyright 2006-2011 Strobe Inc.
* Portions Copyright 2008-2011 Apple Inc. All rights reserved.
* @license Licensed under MIT license
* See https://raw.github.com/emberjs/ember.js/master/LICENSE
- * @version 2.15.0-beta.1
+ * @version 2.15.0-beta.2
*/
var enifed, requireModule, Ember;
var mainContext = this; // Used in ember-environment/lib/global.js
@@ -8798,11 +8798,10 @@
'xmlns:xlink': XMLNS
};
// import Logger from './logger';
// let alreadyWarned = false;
- // import Logger from './logger';
function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
@@ -12561,18 +12560,18 @@
cloneParentDependencies: function () {
var _this2 = this;
var parent = (0, _engineParent.getEngineParent)(this);
- ['route:basic', 'event_dispatcher:main', 'service:-routing', 'service:-glimmer-environment'].forEach(function (key) {
+ ['route:basic', 'service:-routing', 'service:-glimmer-environment'].forEach(function (key) {
return _this2.register(key, parent.resolveRegistration(key));
});
var env = parent.lookup('-environment:main');
this.register('-environment:main', env, { instantiate: false });
- var singletons = ['router:main', (0, _container.privatize)(_templateObject), '-view-registry:main', 'renderer:-' + (env.isInteractive ? 'dom' : 'inert'), 'service:-document'];
+ var singletons = ['router:main', (0, _container.privatize)(_templateObject), '-view-registry:main', 'renderer:-' + (env.isInteractive ? 'dom' : 'inert'), 'service:-document', 'event_dispatcher:main'];
singletons.forEach(function (key) {
return _this2.register(key, parent.lookup(key), { instantiate: false });
});
@@ -13727,10 +13726,11 @@
</ul>
@public
@static
@method registerDeprecationHandler
+ @for Ember.Debug
@param handler {Function} A function to handle deprecation calls.
@since 2.1.0
*/
/*global __fail__*/
@@ -13765,17 +13765,11 @@
return _ret = new EmberError(message), (0, _emberBabel.possibleConstructorReturn)(_this, _ret);
}
var error = Error.call(_this, message);
-
- if (Error.captureStackTrace) {
- Error.captureStackTrace(_this, EmberError);
- } else {
- _this.stack = error.stack;
- }
-
+ _this.stack = error.stack;
_this.description = error.description;
_this.fileName = error.fileName;
_this.lineNumber = error.lineNumber;
_this.message = error.message;
_this.name = error.name;
@@ -15944,11 +15938,39 @@
## Layouts
See [Ember.Templates.helpers.yield](/api/classes/Ember.Templates.helpers.html#method_yield)
for more information.
+ Layout can be used to wrap content in a component. In addition
+ to wrapping content in a Component's template, you can also use
+ the public layout API in your Component JavaScript.
+ ```app/templates/components/person-profile.hbs
+ <h1>Person's Title</h1>
+ <div class='details'>{{yield}}</div>
+ ```
+
+ ```app/components/person-profile.js
+ import Ember from 'ember';
+ import layout from '../templates/components/person-profile';
+
+ export default Ember.Component.extend({
+ layout
+ });
+ ```
+
+ The above will result in the following HTML output:
+
+ ```html
+ <h1>Person's Title</h1>
+ <div class="details">
+ <h2>Chief Basket Weaver</h2>
+ <h3>Fisherman Industries</h3>
+ </div>
+ ```
+
+
## Responding to Browser Events
Components can respond to user-initiated events in one of three ways: method
implementation, through an event manager, and through `{{action}}` helper use
in their template or layout.
@@ -17454,10 +17476,19 @@
this[RECOMPUTE_TAG] = new _reference.DirtyableTag();
},
recompute: function () {
this[RECOMPUTE_TAG].dirty();
}
+
+ /**
+ Override this function when writing a class-based helper.
+ @method compute
+ @param {Array} params The positional arguments to the helper
+ @param {Object} hash The named arguments to the helper
+ @public
+ @since 1.13.0
+ */
});
Helper.reopenClass({
isHelperFactory: true
});
@@ -18312,15 +18343,15 @@
return GetHelperReference;
}(_references.CachedReference);
});
enifed("ember-glimmer/helpers/hash", ["exports"], function (exports) {
- "use strict";
+ "use strict";
- exports.default = function (vm, args) {
- return args.named.capture();
- };
+ exports.default = function (vm, args) {
+ return args.named.capture();
+ };
});
enifed('ember-glimmer/helpers/if-unless', ['exports', 'ember-babel', 'ember-debug', 'ember-glimmer/utils/references', '@glimmer/reference'], function (exports, _emberBabel, _emberDebug, _references, _reference) {
'use strict';
exports.inlineIf =
@@ -23951,27 +23982,23 @@
var pointer = obj;
var meta = void 0;
while (pointer !== undefined && pointer !== null) {
meta = metaStore.get(pointer);
// jshint loopfunc:true
- if (meta === null || meta !== undefined) {
+ if (meta !== undefined) {
return meta;
}
pointer = getPrototypeOf(pointer);
}
};
} else {
setMeta = function (obj, meta) {
- // if `null` already, just set it to the new value
- // otherwise define property first
- if (obj[META_FIELD] !== null) {
- if (obj.__defineNonEnumerable) {
- obj.__defineNonEnumerable(EMBER_META_PROPERTY);
- } else {
- Object.defineProperty(obj, META_FIELD, META_DESC);
- }
+ if (obj.__defineNonEnumerable) {
+ obj.__defineNonEnumerable(EMBER_META_PROPERTY);
+ } else {
+ Object.defineProperty(obj, META_FIELD, META_DESC);
}
obj[META_FIELD] = meta;
};
@@ -24008,11 +24035,11 @@
function meta(obj) {
var maybeMeta = exports.peekMeta(obj);
var parent = void 0;
// remove this code, in-favor of explicit parent
- if (maybeMeta !== undefined && maybeMeta !== null) {
+ if (maybeMeta !== undefined) {
if (maybeMeta.source === obj) {
return maybeMeta;
}
parent = maybeMeta;
}
@@ -29576,14 +29603,36 @@
/**
Ember.HistoryLocation implements the location API using the browser's
history.pushState API.
+ Using `HistoryLocation` results in URLs that are indistinguishable from a
+ standard URL. This relies upon the browser's `history` API.
+
+ Example:
+
+ ```javascript
+ App.Router.map(function() {
+ this.route('posts', function() {
+ this.route('new');
+ });
+ });
+
+ App.Router.reopen({
+ location: 'history'
+ });
+ ```
+
+ This will result in a posts.new url of `/posts/new`.
+
+ Keep in mind that your server must serve the Ember app at all the routes you
+ define.
+
@class HistoryLocation
@namespace Ember
@extends Ember.Object
- @private
+ @protected
*/
exports.default = _emberRuntime.Object.extend({
implementation: 'history',
init: function () {
@@ -36736,11 +36785,16 @@
}
}
var adding = void 0,
lim,
- idx;
+ idx,
+ length,
+ addedAmount,
+ removedAmount,
+ previousLength,
+ normalStartIdx;
if (startIdx >= 0 && addAmt >= 0 && (0, _emberMetal.get)(array, 'hasEnumerableObservers')) {
adding = [];
lim = startIdx + addAmt;
@@ -36759,21 +36813,30 @@
(0, _emberMetal.sendEvent)(array, '@array:change', [array, startIdx, removeAmt, addAmt]);
var meta = (0, _emberMetal.peekMeta)(array);
var cache = meta && meta.readableCache();
+ if (cache !== undefined) {
+ length = (0, _emberMetal.get)(array, 'length');
+ addedAmount = addAmt === -1 ? 0 : addAmt;
+ removedAmount = removeAmt === -1 ? 0 : removeAmt;
+ previousLength = length - (addedAmount - removedAmount);
+ normalStartIdx = startIdx < 0 ? previousLength + startIdx : startIdx;
- if (cache) {
- if (cache.firstObject !== undefined && objectAt(array, 0) !== _emberMetal.cacheFor.get(cache, 'firstObject')) {
- (0, _emberMetal.propertyWillChange)(array, 'firstObject', meta);
- (0, _emberMetal.propertyDidChange)(array, 'firstObject', meta);
+ if (cache.firstObject !== undefined && normalStartIdx === 0) {
+ (0, _emberMetal.propertyWillChange)(array, 'firstObject');
+ (0, _emberMetal.propertyDidChange)(array, 'firstObject');
}
- if (cache.lastObject !== undefined && objectAt(array, (0, _emberMetal.get)(array, 'length') - 1) !== _emberMetal.cacheFor.get(cache, 'lastObject')) {
- (0, _emberMetal.propertyWillChange)(array, 'lastObject', meta);
- (0, _emberMetal.propertyDidChange)(array, 'lastObject', meta);
+
+ if (cache.lastObject !== undefined) {
+ if (previousLength - 1 < normalStartIdx + removedAmount) {
+ (0, _emberMetal.propertyWillChange)(array, 'lastObject');
+ (0, _emberMetal.propertyDidChange)(array, 'lastObject');
+ }
}
}
+
return array;
}
var EMBER_ARRAY = (0, _emberUtils.symbol)('EMBER_ARRAY');
@@ -36921,11 +36984,11 @@
@private
*/
function EachProxy(content) {
this._content = content;
this._keys = undefined;
- this.__ember_meta__ = null;
+ (0, _emberMetal.meta)(this);
}
EachProxy.prototype = {
__defineNonEnumerable: function (property) {
this[property.name] = property.descriptor.value;
@@ -43702,25 +43765,25 @@
exports.default = Object.create(_default2.default);
});
enifed('ember/features', ['exports', 'ember-environment', 'ember-utils'], function (exports, _emberEnvironment, _emberUtils) {
'use strict';
- exports.EMBER_GLIMMER_DETECT_BACKTRACKING_RERENDER = exports.MANDATORY_SETTER = exports.GLIMMER_CUSTOM_COMPONENT_MANAGER = exports.EMBER_MODULE_UNIFICATION = exports.EMBER_ENGINES_MOUNT_PARAMS = exports.EMBER_ROUTING_ROUTER_SERVICE = exports.EMBER_GLIMMER_ALLOW_BACKTRACKING_RERENDER = exports.EMBER_METAL_WEAKMAP = exports.EMBER_IMPROVED_INSTRUMENTATION = exports.EMBER_LIBRARIES_ISREGISTERED = exports.FEATURES_STRIPPED_TEST = exports.FEATURES = exports.DEFAULT_FEATURES = undefined;
+ exports.FEATURES = exports.DEFAULT_FEATURES = undefined;
var DEFAULT_FEATURES = exports.DEFAULT_FEATURES = { "features-stripped-test": false, "ember-libraries-isregistered": false, "ember-improved-instrumentation": false, "ember-metal-weakmap": false, "ember-glimmer-allow-backtracking-rerender": false, "ember-routing-router-service": true, "ember-engines-mount-params": true, "ember-module-unification": false, "glimmer-custom-component-manager": false, "mandatory-setter": false, "ember-glimmer-detect-backtracking-rerender": false };
var FEATURES = exports.FEATURES = (0, _emberUtils.assign)(DEFAULT_FEATURES, _emberEnvironment.ENV.FEATURES);
- var FEATURES_STRIPPED_TEST = exports.FEATURES_STRIPPED_TEST = FEATURES["features-stripped-test"];
- var EMBER_LIBRARIES_ISREGISTERED = exports.EMBER_LIBRARIES_ISREGISTERED = FEATURES["ember-libraries-isregistered"];
- var EMBER_IMPROVED_INSTRUMENTATION = exports.EMBER_IMPROVED_INSTRUMENTATION = FEATURES["ember-improved-instrumentation"];
- var EMBER_METAL_WEAKMAP = exports.EMBER_METAL_WEAKMAP = FEATURES["ember-metal-weakmap"];
- var EMBER_GLIMMER_ALLOW_BACKTRACKING_RERENDER = exports.EMBER_GLIMMER_ALLOW_BACKTRACKING_RERENDER = FEATURES["ember-glimmer-allow-backtracking-rerender"];
- var EMBER_ROUTING_ROUTER_SERVICE = exports.EMBER_ROUTING_ROUTER_SERVICE = FEATURES["ember-routing-router-service"];
- var EMBER_ENGINES_MOUNT_PARAMS = exports.EMBER_ENGINES_MOUNT_PARAMS = FEATURES["ember-engines-mount-params"];
- var EMBER_MODULE_UNIFICATION = exports.EMBER_MODULE_UNIFICATION = FEATURES["ember-module-unification"];
- var GLIMMER_CUSTOM_COMPONENT_MANAGER = exports.GLIMMER_CUSTOM_COMPONENT_MANAGER = FEATURES["glimmer-custom-component-manager"];
- var MANDATORY_SETTER = exports.MANDATORY_SETTER = FEATURES["mandatory-setter"];
- var EMBER_GLIMMER_DETECT_BACKTRACKING_RERENDER = exports.EMBER_GLIMMER_DETECT_BACKTRACKING_RERENDER = FEATURES["ember-glimmer-detect-backtracking-rerender"];
+ false;
+ false;
+ false;
+ false;
+ false;
+ true;
+ true;
+ false;
+ false;
+ false;
+ false;
});
enifed('ember/index', ['exports', 'require', 'ember-environment', 'node-module', 'ember-utils', 'container', 'ember-metal', 'ember/features', 'ember-debug', 'backburner', 'ember-console', 'ember-runtime', 'ember-glimmer', 'ember/version', 'ember-views', 'ember-routing', 'ember-application', 'ember-extension-support'], function (exports, _require2, _emberEnvironment, _nodeModule, _emberUtils, _container, _emberMetal, _features, _emberDebug, _backburner, _emberConsole, _emberRuntime, _emberGlimmer, _version, _emberViews, _emberRouting, _emberApplication, _emberExtensionSupport) {
'use strict';
exports.VERSION = undefined;
@@ -44230,11 +44293,11 @@
}
});
enifed("ember/version", ["exports"], function (exports) {
"use strict";
- exports.default = "2.15.0-beta.1";
+ exports.default = "2.15.0-beta.2";
});
enifed('node-module', ['exports'], function(_exports) {
var IS_NODE = typeof module === 'object' && typeof module.require === 'function';
if (IS_NODE) {
_exports.require = module.require;
@@ -47287,14 +47350,16 @@
enifed('rsvp', ['exports', 'ember-babel', 'node-module'], function (exports, _emberBabel, _nodeModule) {
'use strict';
exports.filter = exports.async = exports.map = exports.reject = exports.resolve = exports.off = exports.on = exports.configure = exports.denodeify = exports.defer = exports.rethrow = exports.hashSettled = exports.hash = exports.race = exports.allSettled = exports.all = exports.EventTarget = exports.Promise = exports.cast = exports.asap = undefined;
- var _rsvp;
+ var _rsvp, callbacks;
function indexOf(callbacks, callback) {
- for (var i = 0, l = callbacks.length; i < l; i++) {
+ var i, l;
+
+ for (i = 0, l = callbacks.length; i < l; i++) {
if (callbacks[i] === callback) {
return i;
}
}
@@ -47359,15 +47424,16 @@
}
},
trigger: function (eventName, options, label) {
var allCallbacks = callbacksFor(this),
callbacks = void 0,
- callback = void 0;
+ callback = void 0,
+ i;
if (callbacks = allCallbacks[eventName]) {
// Don't cache the callbacks.length since it may grow
- for (var i = 0; i < callbacks.length; i++) {
+ for (i = 0; i < callbacks.length; i++) {
callback = callbacks[i];
callback(options, label);
}
}
@@ -47424,15 +47490,17 @@
var queue = [];
function scheduleFlush() {
setTimeout(function () {
- for (var i = 0; i < queue.length; i++) {
- var entry = queue[i];
+ var i, entry, payload;
- var payload = entry.payload;
+ for (i = 0; i < queue.length; i++) {
+ entry = queue[i];
+ payload = entry.payload;
+
payload.guid = payload.key + payload.id;
payload.childGuid = payload.key + payload.childId;
if (payload.error) {
payload.stack = payload.error.stack;
}
@@ -47655,11 +47723,12 @@
config.async(publish, parent);
}
}
function publish(promise) {
- var subscribers = promise._subscribers;
+ var subscribers = promise._subscribers,
+ i;
var settled = promise._state;
if (config.instrument) {
instrument(settled === FULFILLED ? 'fulfilled' : 'rejected', promise);
}
@@ -47670,11 +47739,11 @@
var child = void 0,
callback = void 0,
result = promise._result;
- for (var i = 0; i < subscribers.length; i += 3) {
+ for (i = 0; i < subscribers.length; i += 3) {
child = subscribers[i];
callback = subscribers[i + settled];
if (child) {
invokeCallback(settled, child, callback, result);
@@ -47753,11 +47822,12 @@
reject(promise, e);
}
}
function then(onFulfillment, onRejection, label) {
- var parent = this;
+ var parent = this,
+ callback;
var state = parent._state;
if (state === FULFILLED && !onFulfillment || state === REJECTED && !onRejection) {
config.instrument && instrument('chained', parent, parent);
return parent;
@@ -47771,114 +47841,125 @@
config.instrument && instrument('chained', parent, child);
if (state === PENDING) {
subscribe(parent, child, onFulfillment, onRejection);
} else {
- var callback = state === FULFILLED ? onFulfillment : onRejection;
+ callback = state === FULFILLED ? onFulfillment : onRejection;
+
config.async(function () {
return invokeCallback(state, child, callback, result);
});
}
return child;
}
- function Enumerator(Constructor, input, abortOnReject, label) {
- this._instanceConstructor = Constructor;
- this.promise = new Constructor(noop, label);
- this._abortOnReject = abortOnReject;
+ var Enumerator = function () {
+ function Enumerator(Constructor, input, abortOnReject, label) {
- this._init.apply(this, arguments);
- }
+ this._instanceConstructor = Constructor;
+ this.promise = new Constructor(noop, label);
+ this._abortOnReject = abortOnReject;
- Enumerator.prototype._init = function (Constructor, input) {
- var len = input.length || 0;
- this.length = len;
- this._remaining = len;
- this._result = new Array(len);
-
- this._enumerate(input);
- if (this._remaining === 0) {
- fulfill(this.promise, this._result);
+ this._init.apply(this, arguments);
}
- };
- Enumerator.prototype._enumerate = function (input) {
- var length = this.length;
- var promise = this.promise;
+ Enumerator.prototype._init = function (Constructor, input) {
+ var len = input.length || 0;
+ this.length = len;
+ this._remaining = len;
+ this._result = new Array(len);
- for (var i = 0; promise._state === PENDING && i < length; i++) {
- this._eachEntry(input[i], i);
- }
- };
+ this._enumerate(input);
+ if (this._remaining === 0) {
+ fulfill(this.promise, this._result);
+ }
+ };
- Enumerator.prototype._settleMaybeThenable = function (entry, i) {
- var c = this._instanceConstructor;
- var resolve$$1 = c.resolve;
+ Enumerator.prototype._enumerate = function (input) {
+ var length = this.length,
+ i;
+ var promise = this.promise;
- if (resolve$$1 === resolve$1) {
- var then$$1 = getThen(entry);
-
- if (then$$1 === then && entry._state !== PENDING) {
- entry._onError = null;
- this._settledAt(entry._state, i, entry._result);
- } else if (typeof then$$1 !== 'function') {
- this._remaining--;
- this._result[i] = this._makeResult(FULFILLED, i, entry);
- } else if (c === Promise) {
- var promise = new c(noop);
- handleMaybeThenable(promise, entry, then$$1);
- this._willSettleAt(promise, i);
- } else {
- this._willSettleAt(new c(function (resolve$$1) {
- return resolve$$1(entry);
- }), i);
+ for (i = 0; promise._state === PENDING && i < length; i++) {
+ this._eachEntry(input[i], i);
}
- } else {
- this._willSettleAt(resolve$$1(entry), i);
- }
- };
+ };
- Enumerator.prototype._eachEntry = function (entry, i) {
- if (isMaybeThenable(entry)) {
- this._settleMaybeThenable(entry, i);
- } else {
- this._remaining--;
- this._result[i] = this._makeResult(FULFILLED, i, entry);
- }
- };
+ Enumerator.prototype._settleMaybeThenable = function (entry, i) {
+ var c = this._instanceConstructor,
+ then$$1,
+ promise;
+ var resolve$$1 = c.resolve;
- Enumerator.prototype._settledAt = function (state, i, value) {
- var promise = this.promise;
+ if (resolve$$1 === resolve$1) {
+ then$$1 = getThen(entry);
- if (promise._state === PENDING) {
- if (this._abortOnReject && state === REJECTED) {
- reject(promise, value);
+
+ if (then$$1 === then && entry._state !== PENDING) {
+ entry._onError = null;
+ this._settledAt(entry._state, i, entry._result);
+ } else if (typeof then$$1 !== 'function') {
+ this._remaining--;
+ this._result[i] = this._makeResult(FULFILLED, i, entry);
+ } else if (c === Promise) {
+ promise = new c(noop);
+
+ handleMaybeThenable(promise, entry, then$$1);
+ this._willSettleAt(promise, i);
+ } else {
+ this._willSettleAt(new c(function (resolve$$1) {
+ return resolve$$1(entry);
+ }), i);
+ }
} else {
+ this._willSettleAt(resolve$$1(entry), i);
+ }
+ };
+
+ Enumerator.prototype._eachEntry = function (entry, i) {
+ if (isMaybeThenable(entry)) {
+ this._settleMaybeThenable(entry, i);
+ } else {
this._remaining--;
- this._result[i] = this._makeResult(state, i, value);
- if (this._remaining === 0) {
- fulfill(promise, this._result);
+ this._result[i] = this._makeResult(FULFILLED, i, entry);
+ }
+ };
+
+ Enumerator.prototype._settledAt = function (state, i, value) {
+ var promise = this.promise;
+
+ if (promise._state === PENDING) {
+ if (this._abortOnReject && state === REJECTED) {
+ reject(promise, value);
+ } else {
+ this._remaining--;
+ this._result[i] = this._makeResult(state, i, value);
+ if (this._remaining === 0) {
+ fulfill(promise, this._result);
+ }
}
}
- }
- };
+ };
- Enumerator.prototype._makeResult = function (state, i, value) {
- return value;
- };
+ Enumerator.prototype._makeResult = function (state, i, value) {
+ return value;
+ };
- Enumerator.prototype._willSettleAt = function (promise, i) {
- var enumerator = this;
+ Enumerator.prototype._willSettleAt = function (promise, i) {
+ var enumerator = this;
- subscribe(promise, undefined, function (value) {
- return enumerator._settledAt(FULFILLED, i, value);
- }, function (reason) {
- return enumerator._settledAt(REJECTED, i, reason);
- });
- };
+ subscribe(promise, undefined, function (value) {
+ return enumerator._settledAt(FULFILLED, i, value);
+ }, function (reason) {
+ return enumerator._settledAt(REJECTED, i, reason);
+ });
+ };
+ return Enumerator;
+ }();
+
function makeSettledResult(state, position, value) {
if (state === FULFILLED) {
return {
state: 'fulfilled',
value: value
@@ -47936,17 +48017,12 @@
Useful for tooling.
@return {Promise} promise that is fulfilled when all `promises` have been
fulfilled, or rejected if any of them become rejected.
@static
*/
- function all(entries, label) {
- if (!isArray(entries)) {
- return this.reject(new TypeError("Promise.all must be called with an array"), label);
- }
- return new Enumerator(this, entries, true /* abort on reject */, label).promise;
- }
+
/**
`RSVP.Promise.race` returns a new promise which is settled in the same way as the
first passed promise to settle.
Example:
@@ -48009,32 +48085,12 @@
@param {String} label optional string for describing the promise returned.
Useful for tooling.
@return {Promise} a promise which settles in the same way as the first passed
promise to settle.
*/
- function race(entries, label) {
- /*jshint validthis:true */
- var Constructor = this;
- var promise = new Constructor(noop, label);
- if (!isArray(entries)) {
- reject(promise, new TypeError('Promise.race must be called with an array'));
- return promise;
- }
-
- for (var i = 0; promise._state === PENDING && i < entries.length; i++) {
- subscribe(Constructor.resolve(entries[i]), undefined, function (value) {
- return resolve(promise, value);
- }, function (reason) {
- return reject(promise, reason);
- });
- }
-
- return promise;
- }
-
/**
`RSVP.Promise.reject` returns a promise rejected with the passed `reason`.
It is shorthand for the following:
```javascript
@@ -48066,18 +48122,12 @@
@param {*} reason value that the returned promise will be rejected with.
@param {String} label optional string for identifying the returned promise.
Useful for tooling.
@return {Promise} a promise rejected with the given `reason`.
*/
- function reject$1(reason, label) {
- /*jshint validthis:true */
- var Constructor = this;
- var promise = new Constructor(noop, label);
- reject(promise, reason);
- return promise;
- }
+
var guidKey = 'rsvp_' + now() + '-';
var counter = 0;
function needsResolver() {
throw new TypeError('You must pass a resolver function as the first argument to the promise constructor');
@@ -48189,127 +48239,97 @@
@param {function} resolver
@param {String} label optional string for labeling the promise.
Useful for tooling.
@constructor
*/
- function Promise(resolver, label) {
- this._id = counter++;
- this._label = label;
- this._state = undefined;
- this._result = undefined;
- this._subscribers = [];
- config.instrument && instrument('created', this);
+ var Promise = function () {
+ function Promise(resolver, label) {
- if (noop !== resolver) {
- typeof resolver !== 'function' && needsResolver();
- this instanceof Promise ? initializePromise(this, resolver) : needsNew();
- }
- }
+ this._id = counter++;
+ this._label = label;
+ this._state = undefined;
+ this._result = undefined;
+ this._subscribers = [];
- Promise.prototype._onError = function (reason) {
- var _this = this;
+ config.instrument && instrument('created', this);
- config.after(function () {
- if (_this._onError) {
- config.trigger('error', reason, _this._label);
+ if (noop !== resolver) {
+ typeof resolver !== 'function' && needsResolver();
+ this instanceof Promise ? initializePromise(this, resolver) : needsNew();
}
- });
- };
+ }
- /**
- `catch` is simply sugar for `then(undefined, onRejection)` which makes it the same
- as the catch block of a try/catch statement.
-
- ```js
- function findAuthor(){
- throw new Error('couldn\'t find that author');
+ Promise.prototype._onError = function (reason) {
+ var _this = this;
+
+ config.after(function () {
+ if (_this._onError) {
+ config.trigger('error', reason, _this._label);
+ }
+ });
+ };
+
+ Promise.prototype.catch = function (onRejection, label) {
+ return this.then(undefined, onRejection, label);
+ };
+
+ Promise.prototype.finally = function (callback, label) {
+ var promise = this;
+ var constructor = promise.constructor;
+
+ return promise.then(function (value) {
+ return constructor.resolve(callback()).then(function () {
+ return value;
+ });
+ }, function (reason) {
+ return constructor.resolve(callback()).then(function () {
+ throw reason;
+ });
+ }, label);
+ };
+
+ return Promise;
+ }();
+
+ Promise.cast = resolve$1; // deprecated
+ Promise.all = function (entries, label) {
+ if (!isArray(entries)) {
+ return this.reject(new TypeError("Promise.all must be called with an array"), label);
}
-
- // synchronous
- try {
- findAuthor();
- } catch(reason) {
- // something went wrong
- }
-
- // async with promises
- findAuthor().catch(function(reason){
- // something went wrong
- });
- ```
-
- @method catch
- @param {Function} onRejection
- @param {String} label optional string for labeling the promise.
- Useful for tooling.
- @return {Promise}
- */
- Promise.prototype.catch = function (onRejection, label) {
- return this.then(undefined, onRejection, label);
+ return new Enumerator(this, entries, true /* abort on reject */, label).promise;
};
+ Promise.race = function (entries, label) {
+ /*jshint validthis:true */
+ var Constructor = this,
+ i;
- /**
- `finally` will be invoked regardless of the promise's fate just as native
- try/catch/finally behaves
-
- Synchronous example:
-
- ```js
- findAuthor() {
- if (Math.random() > 0.5) {
- throw new Error();
- }
- return new Author();
+ var promise = new Constructor(noop, label);
+
+ if (!isArray(entries)) {
+ reject(promise, new TypeError('Promise.race must be called with an array'));
+ return promise;
}
-
- try {
- return findAuthor(); // succeed or fail
- } catch(error) {
- return findOtherAuthor();
- } finally {
- // always runs
- // doesn't affect the return value
- }
- ```
-
- Asynchronous example:
-
- ```js
- findAuthor().catch(function(reason){
- return findOtherAuthor();
- }).finally(function(){
- // author was either found, or not
- });
- ```
-
- @method finally
- @param {Function} callback
- @param {String} label optional string for labeling the promise.
- Useful for tooling.
- @return {Promise}
- */
- Promise.prototype.finally = function (callback, label) {
- var promise = this;
- var constructor = promise.constructor;
- return promise.then(function (value) {
- return constructor.resolve(callback()).then(function () {
- return value;
+ for (i = 0; promise._state === PENDING && i < entries.length; i++) {
+ subscribe(Constructor.resolve(entries[i]), undefined, function (value) {
+ return resolve(promise, value);
+ }, function (reason) {
+ return reject(promise, reason);
});
- }, function (reason) {
- return constructor.resolve(callback()).then(function () {
- throw reason;
- });
- }, label);
- };
+ }
- Promise.cast = resolve$1; // deprecated
- Promise.all = all;
- Promise.race = race;
+ return promise;
+ };
Promise.resolve = resolve$1;
- Promise.reject = reject$1;
+ Promise.reject = function (reason, label) {
+ /*jshint validthis:true */
+ var Constructor = this;
+ var promise = new Constructor(noop, label);
+ reject(promise, reason);
+ return promise;
+ };
Promise.prototype._guidKey = guidKey;
/**
The primary way of interacting with a promise is through its `then` method,
@@ -48531,31 +48551,36 @@
return ERROR;
}
}
function makeObject(_, argumentNames) {
- var obj = {};
+ var obj = {},
+ x,
+ i,
+ name;
var length = _.length;
var args = new Array(length);
- for (var x = 0; x < length; x++) {
+ for (x = 0; x < length; x++) {
args[x] = _[x];
}
- for (var i = 0; i < argumentNames.length; i++) {
- var name = argumentNames[i];
+ for (i = 0; i < argumentNames.length; i++) {
+ name = argumentNames[i];
+
obj[name] = args[i + 1];
}
return obj;
}
function arrayResult(_) {
- var length = _.length;
+ var length = _.length,
+ i;
var args = new Array(length - 1);
- for (var i = 1; i < length; i++) {
+ for (i = 1; i < length; i++) {
args[i - 1] = _[i];
}
return args;
}
@@ -48696,23 +48721,28 @@
`RSVP.Promise`
@static
*/
function denodeify(nodeFunc, options) {
var fn = function () {
- var self = this;
+ var self = this,
+ i,
+ arg,
+ p;
var l = arguments.length;
var args = new Array(l + 1);
var promiseInput = false;
- for (var i = 0; i < l; ++i) {
- var arg = arguments[i];
+ for (i = 0; i < l; ++i) {
+ arg = arguments[i];
+
if (!promiseInput) {
// TODO: clean this up
promiseInput = needsPromiseInput(arg);
if (promiseInput === GET_THEN_ERROR$1) {
- var p = new Promise(noop);
+ p = new Promise(noop);
+
reject(p, GET_THEN_ERROR$1.value);
return p;
} else if (promiseInput && promiseInput !== true) {
arg = wrapThenable(promiseInput, arg);
}
@@ -48733,11 +48763,10 @@
}
};
(0, _emberBabel.defaults)(fn, nodeFunc);
-
return fn;
}
function handleValueInput(promise, args, nodeFunc, self) {
var result = tryApply(nodeFunc, self, args);
@@ -48785,11 +48814,10 @@
var AllSettled = function (_Enumerator) {
(0, _emberBabel.inherits)(AllSettled, _Enumerator);
function AllSettled(Constructor, entries, label) {
- (0, _emberBabel.classCallCheck)(this, AllSettled);
return (0, _emberBabel.possibleConstructorReturn)(this, _Enumerator.call(this, Constructor, entries, false /* don't abort on reject */, label));
}
return AllSettled;
}(Enumerator);
@@ -48869,25 +48897,26 @@
(0, _emberBabel.inherits)(PromiseHash, _Enumerator2);
function PromiseHash(Constructor, object) {
var abortOnReject = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
var label = arguments[3];
- (0, _emberBabel.classCallCheck)(this, PromiseHash);
+
return (0, _emberBabel.possibleConstructorReturn)(this, _Enumerator2.call(this, Constructor, object, abortOnReject, label));
}
- PromiseHash.prototype._init = function _init(Constructor, object) {
+ PromiseHash.prototype._init = function (Constructor, object) {
this._result = {};
this._enumerate(object);
if (this._remaining === 0) {
fulfill(this.promise, this._result);
}
};
- PromiseHash.prototype._enumerate = function _enumerate(input) {
- var promise = this.promise;
+ PromiseHash.prototype._enumerate = function (input) {
+ var promise = this.promise,
+ i;
var results = [];
for (var key in input) {
if (hasOwnProperty.call(input, key)) {
results.push({
@@ -48899,11 +48928,11 @@
var length = results.length;
this._remaining = length;
var result = void 0;
- for (var i = 0; promise._state === PENDING && i < length; i++) {
+ for (i = 0; promise._state === PENDING && i < length; i++) {
result = results[i];
this._eachEntry(result.entry, result.position);
}
};
@@ -49008,11 +49037,10 @@
var HashSettled = function (_PromiseHash) {
(0, _emberBabel.inherits)(HashSettled, _PromiseHash);
function HashSettled(Constructor, object, label) {
- (0, _emberBabel.classCallCheck)(this, HashSettled);
return (0, _emberBabel.possibleConstructorReturn)(this, _PromiseHash.call(this, Constructor, object, false, label));
}
return HashSettled;
}(PromiseHash);
@@ -49306,14 +49334,15 @@
if (!isFunction(mapFn)) {
return Promise.reject(new TypeError("RSVP.map expects a function as a second argument"), label);
}
return Promise.all(promises, label).then(function (values) {
- var length = values.length;
+ var length = values.length,
+ i;
var results = new Array(length);
- for (var i = 0; i < length; i++) {
+ for (i = 0; i < length; i++) {
results[i] = mapFn(values[i]);
}
return Promise.all(results, label);
});
@@ -49455,22 +49484,24 @@
return Promise.reject(new TypeError("RSVP.filter expects function as a second argument"), label);
}
var promise = isArray(promises) ? resolveAll(promises, label) : resolveSingle(promises, label);
return promise.then(function (values) {
- var length = values.length;
+ var length = values.length,
+ i;
var filtered = new Array(length);
- for (var i = 0; i < length; i++) {
+ for (i = 0; i < length; i++) {
filtered[i] = filterFn(values[i]);
}
return resolveAll(filtered, label).then(function (filtered) {
- var results = new Array(length);
+ var results = new Array(length),
+ _i;
var newLength = 0;
- for (var _i = 0; _i < length; _i++) {
+ for (_i = 0; _i < length; _i++) {
if (filtered[_i]) {
results[newLength] = values[_i];
newLength++;
}
}
@@ -49555,27 +49586,33 @@
}
var queue$1 = new Array(1000);
function flush() {
- for (var i = 0; i < len; i += 2) {
- var callback = queue$1[i];
- var arg = queue$1[i + 1];
+ var i, callback, arg;
+ for (i = 0; i < len; i += 2) {
+ callback = queue$1[i];
+ arg = queue$1[i + 1];
+
+
callback(arg);
queue$1[i] = undefined;
queue$1[i + 1] = undefined;
}
len = 0;
}
function attemptVertex() {
+ var r, vertx;
+
try {
- var r = _nodeModule.require;
- var vertx = r('vertx');
+ r = _nodeModule.require;
+ vertx = r('vertx');
+
vertxNext = vertx.runOnLoop || vertx.runOnContext;
return useVertxTimer();
} catch (e) {
return useSetTimeout();
}
@@ -49593,19 +49630,17 @@
scheduleFlush$1 = attemptVertex();
} else {
scheduleFlush$1 = useSetTimeout();
}
- var platform = void 0;
-
/* global self */
if (typeof self === 'object') {
- platform = self;
+ self;
/* global global */
} else if (typeof global === 'object') {
- platform = global;
+ global;
} else {
throw new Error('no global: `self` or `global` found');
}
// defaults
@@ -49627,10 +49662,11 @@
config['off'].apply(config, arguments);
}
// Set up instrumentation through `window.__PROMISE_INTRUMENTATION__`
if (typeof window !== 'undefined' && typeof window['__PROMISE_INSTRUMENTATION__'] === 'object') {
- var callbacks = window['__PROMISE_INSTRUMENTATION__'];
+ callbacks = window['__PROMISE_INSTRUMENTATION__'];
+
configure('instrument', true);
for (var eventName in callbacks) {
if (callbacks.hasOwnProperty(eventName)) {
on(eventName, callbacks[eventName]);
}