Socket
Socket
Sign inDemoInstall

rsvp

Package Overview
Dependencies
0
Maintainers
6
Versions
51
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 4.7.0 to 4.8.0

5

CHANGELOG.md
# Master
* reject promise when non-array promise is passed to RSVP.filter
* fix issue with registering event callbacks
* remove publishing to S3 and rely on `npm` and `jsdelivr.com` instead
* general cleanup
# 4.7.0

@@ -4,0 +9,0 @@

2

dist/rsvp.min.js

@@ -1,1 +0,1 @@

(function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(t.RSVP=t.RSVP||{})})(this,function(t){"use strict";function e(t){var e=t._promiseCallbacks;e||(e=t._promiseCallbacks={});return e}function r(t,e){if(2!==arguments.length)return gt[t];gt[t]=e}function n(){setTimeout(function(){for(var t=0;t<jt.length;t++){var e=jt[t],r=e.payload;r.guid=r.key+r.id;r.childGuid=r.key+r.childId;r.error&&(r.stack=r.error.stack);gt.trigger(e.name,e.payload)}jt.length=0},50)}function o(t,e,r){1===jt.push({name:t,payload:{key:e._guidKey,id:e._id,eventName:t,detail:e._result,childId:r&&r._id,label:e._label,timeStamp:Date.now(),error:gt["instrument-with-stack"]?new Error(e._label):null}})&&n()}function i(t,e){var r=this;if(t&&"object"==typeof t&&t.constructor===r)return t;var n=new r(c,e);v(n,t);return n}function u(){return new TypeError("A promises callback cannot return that same promise.")}function s(t){var e=typeof t;return null!==t&&("object"===e||"function"===e)}function c(){}function a(){this.error=null}function f(t){try{return t.then}catch(e){Tt.error=e;return Tt}}function l(){try{var t=St;St=null;return t.apply(this,arguments)}catch(e){Pt.error=e;return Pt}}function h(t){St=t;return l}function p(t,e,r,n){try{t.call(e,r,n)}catch(o){return o}}function y(t,e,r){gt.async(function(t){var n=!1,o=p(r,e,function(r){if(!n){n=!0;e!==r?v(t,r,void 0):m(t,r)}},function(e){if(!n){n=!0;w(t,e)}},"Settle: "+(t._label||" unknown promise"));if(!n&&o){n=!0;w(t,o)}},t)}function _(t,e){if(e._state===Ot)m(t,e._result);else if(e._state===At){e._onError=null;w(t,e._result)}else g(e,void 0,function(r){e===r?m(t,r):v(t,r)},function(e){return w(t,e)})}function d(t,e,r){var n=e.constructor===t.constructor&&r===A&&t.constructor.resolve===i;if(n)_(t,e);else if(r===Tt){var o=Tt.error;Tt.error=null;w(t,o)}else"function"==typeof r?y(t,e,r):m(t,e)}function v(t,e){t===e?m(t,e):s(e)?d(t,e,f(e)):m(t,e)}function b(t){t._onError&&t._onError(t._result);j(t)}function m(t,e){if(t._state===Et){t._result=e;t._state=Ot;0===t._subscribers.length?gt.instrument&&o("fulfilled",t):gt.async(j,t)}}function w(t,e){if(t._state===Et){t._state=At;t._result=e;gt.async(b,t)}}function g(t,e,r,n){var o=t._subscribers,i=o.length;t._onError=null;o[i]=e;o[i+Ot]=r;o[i+At]=n;0===i&&t._state&&gt.async(j,t)}function j(t){var e=t._subscribers,r=t._state;gt.instrument&&o(r===Ot?"fulfilled":"rejected",t);if(0!==e.length){for(var n=void 0,i=void 0,u=t._result,s=0;s<e.length;s+=3){n=e[s];i=e[s+r];n?E(r,n,i,u):i(u)}t._subscribers.length=0}}function E(t,e,r,n){var o="function"==typeof r,i=void 0;i=o?h(r)(n):n;if(e._state!==Et);else if(i===e)w(e,u());else if(i===Pt){var s=i.error;i.error=null;w(e,s)}else o?v(e,i):t===Ot?m(e,i):t===At&&w(e,i)}function O(t,e){var r=!1;try{e(function(e){if(!r){r=!0;v(t,e)}},function(e){if(!r){r=!0;w(t,e)}})}catch(n){w(t,n)}}function A(t,e,r){var n=this,i=n._state;if(i===Ot&&!t||i===At&&!e){gt.instrument&&o("chained",n,n);return n}n._onError=null;var u=new n.constructor(c,r),s=n._result;gt.instrument&&o("chained",n,u);if(i===Et)g(n,u,t,e);else{var a=i===Ot?t:e;gt.async(function(){return E(i,u,a,s)})}return u}function T(t,e,r){this._remaining--;t===Ot?this._result[e]={state:"fulfilled",value:r}:this._result[e]={state:"rejected",reason:r}}function P(t,e){return Array.isArray(t)?new Rt(this,t,(!0),e).promise:this.reject(new TypeError("Promise.all must be called with an array"),e)}function S(t,e){var r=this,n=new r(c,e);if(!Array.isArray(t)){w(n,new TypeError("Promise.race must be called with an array"));return n}for(var o=0;n._state===Et&&o<t.length;o++)g(r.resolve(t[o]),void 0,function(t){return v(n,t)},function(t){return w(n,t)});return n}function R(t,e){var r=this,n=new r(c,e);w(n,t);return n}function x(){throw new TypeError("You must pass a resolver function as the first argument to the promise constructor")}function k(){throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.")}function M(){this.value=void 0}function C(t){try{return t.then}catch(e){Ct.value=e;return Ct}}function F(t,e,r){try{t.apply(e,r)}catch(n){Ct.value=n;return Ct}}function I(t,e){for(var r={},n=t.length,o=new Array(n),i=0;i<n;i++)o[i]=t[i];for(var u=0;u<e.length;u++){var s=e[u];r[s]=o[u+1]}return r}function N(t){for(var e=t.length,r=new Array(e-1),n=1;n<e;n++)r[n-1]=t[n];return r}function V(t,e){return{then:function(r,n){return t.call(e,r,n)}}}function U(t,e){var r=function(){for(var r=this,n=arguments.length,o=new Array(n+1),i=!1,u=0;u<n;++u){var s=arguments[u];if(!i){i=q(s);if(i===Ft){var a=new Mt(c);w(a,Ft.value);return a}i&&i!==!0&&(s=V(i,s))}o[u]=s}var f=new Mt(c);o[n]=function(t,r){t?w(f,t):void 0===e?v(f,r):e===!0?v(f,N(arguments)):Array.isArray(e)?v(f,I(arguments,e)):v(f,r)};return i?K(f,o,t,r):D(f,o,t,r)};r.__proto__=t;return r}function D(t,e,r,n){var o=F(r,n,e);o===Ct&&w(t,o.value);return t}function K(t,e,r,n){return Mt.all(e).then(function(e){var o=F(r,n,e);o===Ct&&w(t,o.value);return t})}function q(t){return!(!t||"object"!=typeof t)&&(t.constructor===Mt||C(t))}function G(t,e){return Mt.all(t,e)}function L(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function W(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}});e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}function Y(t,e){return Array.isArray(t)?new It(Mt,t,e).promise:Mt.reject(new TypeError("Promise.allSettled must be called with an array"),e)}function $(t,e){return Mt.race(t,e)}function z(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function B(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}});e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}function H(t,e){return null===t||"object"!=typeof t?Mt.reject(new TypeError("Promise.hash must be called with an object"),e):new Vt(Mt,t,e).promise}function J(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function Q(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}});e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}function X(t,e){return null===t||"object"!=typeof t?Mt.reject(new TypeError("RSVP.hashSettled must be called with an object"),e):new Ut(Mt,t,(!1),e).promise}function Z(t){setTimeout(function(){throw t});throw t}function tt(t){var e={resolve:void 0,reject:void 0};e.promise=new Mt(function(t,r){e.resolve=t;e.reject=r},t);return e}function et(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function rt(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}});e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}function nt(t,e,r){return Array.isArray(t)?"function"!=typeof e?Mt.reject(new TypeError("RSVP.map expects a function as a second argument"),r):new Dt(Mt,t,e,r).promise:Mt.reject(new TypeError("RSVP.map must be called with an array"),r)}function ot(t,e){return Mt.resolve(t,e)}function it(t,e){return Mt.reject(t,e)}function ut(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function st(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}});e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}function ct(t,e,r){return Array.isArray(t)||null!==t&&"object"==typeof t&&void 0!==t.then?"function"!=typeof e?Mt.reject(new TypeError("RSVP.filter expects function as a second argument"),r):Mt.resolve(t,r).then(function(t){return new qt(Mt,t,e,r).promise}):Mt.reject(new TypeError("RSVP.filter must be called with an array or promise"),r)}function at(t,e){Ht[Gt]=t;Ht[Gt+1]=e;Gt+=2;2===Gt&&Jt()}function ft(){var t=process.nextTick,e=process.versions.node.match(/^(?:(\d+)\.)?(?:(\d+)\.)?(\*|\d+)$/);Array.isArray(e)&&"0"===e[1]&&"10"===e[2]&&(t=setImmediate);return function(){return t(_t)}}function lt(){return"undefined"!=typeof Lt?function(){Lt(_t)}:yt()}function ht(){var t=0,e=new $t(_t),r=document.createTextNode("");e.observe(r,{characterData:!0});return function(){return r.data=t=++t%2}}function pt(){var t=new MessageChannel;t.port1.onmessage=_t;return function(){return t.port2.postMessage(0)}}function yt(){return function(){return setTimeout(_t,1)}}function _t(){for(var t=0;t<Gt;t+=2){var e=Ht[t],r=Ht[t+1];e(r);Ht[t]=void 0;Ht[t+1]=void 0}Gt=0}function dt(){try{var t=require,e=t("vertx");Lt=e.runOnLoop||e.runOnContext;return lt()}catch(r){return yt()}}function vt(t,e,r){e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r;return t}function bt(){gt.on.apply(gt,arguments)}function mt(){gt.off.apply(gt,arguments)}var wt={mixin:function(t){t.on=this.on;t.off=this.off;t.trigger=this.trigger;t._promiseCallbacks=void 0;return t},on:function(t,r){if("function"!=typeof r)throw new TypeError("Callback must be a function");var n=e(this),o=void 0;o=n[t];o||(o=n[t]=[]);o.indexOf(r)&&o.push(r)},off:function(t,r){var n=e(this),o=void 0,i=void 0;if(r){o=n[t];i=o.indexOf(r);i!==-1&&o.splice(i,1)}else n[t]=[]},trigger:function(t,r,n){var o=e(this),i=void 0,u=void 0;if(i=o[t])for(var s=0;s<i.length;s++){u=i[s];u(r,n)}}},gt={instrument:!1};wt.mixin(gt);var jt=[],Et=void 0,Ot=1,At=2,Tt=new a,Pt=new a,St=void 0,Rt=function(){function t(t,e,r,n){this._instanceConstructor=t;this.promise=new t(c,n);this._abortOnReject=r;this.isUsingOwnPromise=t===Mt;this._init.apply(this,arguments)}t.prototype._init=function(t,e){var r=e.length||0;this.length=r;this._remaining=r;this._result=new Array(r);this._enumerate(e)};t.prototype._enumerate=function(t){for(var e=this.length,r=this.promise,n=0;r._state===Et&&n<e;n++)this._eachEntry(t[n],n,!0);this._checkFullfillment()};t.prototype._checkFullfillment=function(){0===this._remaining&&m(this.promise,this._result)};t.prototype._settleMaybeThenable=function(t,e,r){var n=this._instanceConstructor,o=n.resolve;if(o===i){var u=f(t);if(u===A&&t._state!==Et){t._onError=null;this._settledAt(t._state,e,t._result,r)}else if("function"!=typeof u)this._settledAt(Ot,e,t,r);else if(this.isUsingOwnPromise){var s=new n(c);d(s,t,u);this._willSettleAt(s,e,r)}else this._willSettleAt(new n(function(e){return e(t)}),e,r)}else this._willSettleAt(o(t),e,r)};t.prototype._eachEntry=function(t,e,r){null!==t&&"object"==typeof t?this._settleMaybeThenable(t,e,r):this._setResultAt(Ot,e,t,r)};t.prototype._settledAt=function(t,e,r,n){var o=this.promise;if(o._state===Et)if(this._abortOnReject&&t===At)w(o,r);else{this._setResultAt(t,e,r,n);this._checkFullfillment()}};t.prototype._setResultAt=function(t,e,r,n){this._remaining--;this._result[e]=r};t.prototype._willSettleAt=function(t,e,r){var n=this;g(t,void 0,function(t){return n._settledAt(Ot,e,t,r)},function(t){return n._settledAt(At,e,t,r)})};return t}(),xt="rsvp_"+Date.now()+"-",kt=0,Mt=function(){function t(e,r){this._id=kt++;this._label=r;this._state=void 0;this._result=void 0;this._subscribers=[];gt.instrument&&o("created",this);if(c!==e){"function"!=typeof e&&x();this instanceof t?O(this,e):k()}}t.prototype._onError=function(t){var e=this;gt.after(function(){e._onError&&gt.trigger("error",t,e._label)})};t.prototype["catch"]=function(t,e){return this.then(void 0,t,e)};t.prototype["finally"]=function(t,e){var r=this,n=r.constructor;return r.then(function(e){return n.resolve(t()).then(function(){return e})},function(e){return n.resolve(t()).then(function(){throw e})},e)};return t}();Mt.cast=i;Mt.all=P;Mt.race=S;Mt.resolve=i;Mt.reject=R;Mt.prototype._guidKey=xt;Mt.prototype.then=A;var Ct=new M,Ft=new M,It=function(t){function e(e,r,n){return L(this,t.call(this,e,r,!1,n))}W(e,t);return e}(Rt);It.prototype._setResultAt=T;var Nt=Object.prototype.hasOwnProperty,Vt=function(t){function e(e,r){var n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],o=arguments[3];return z(this,t.call(this,e,r,n,o))}B(e,t);e.prototype._init=function(t,e){this._result={};this._enumerate(e);0===this._remaining&&m(this.promise,this._result)};e.prototype._enumerate=function(t){var e=this.promise,r=[];for(var n in t)Nt.call(t,n)&&r.push({position:n,entry:t[n]});var o=r.length;this._remaining=o;for(var i=void 0,u=0;e._state===Et&&u<o;u++){i=r[u];this._eachEntry(i.entry,i.position)}};return e}(Rt),Ut=function(t){function e(e,r,n){return J(this,t.call(this,e,r,!1,n))}Q(e,t);return e}(Vt);Ut.prototype._setResultAt=T;var Dt=function(t){function e(e,r,n,o){return et(this,t.call(this,e,r,!0,o,n))}rt(e,t);e.prototype._init=function(t,e,r,n,o){var i=e.length||0;this.length=i;this._remaining=i;this._result=new Array(i);this._mapFn=o;this._enumerate(e)};e.prototype._setResultAt=function(t,e,r,n){if(n){var o=h(this._mapFn)(r,e);o===Pt?this._settledAt(At,e,o.error,!1):this._eachEntry(o,e,!1)}else{this._remaining--;this._result[e]=r}};return e}(Rt),Kt={},qt=function(t){function e(e,r,n,o){return ut(this,t.call(this,e,r,!0,o,n))}st(e,t);e.prototype._init=function(t,e,r,n,o){var i=e.length||0;this.length=i;this._remaining=i;this._result=new Array(i);this._filterFn=o;this._enumerate(e)};e.prototype._checkFullfillment=function(){if(0===this._remaining){this._result=this._result.filter(function(t){return t!==Kt});m(this.promise,this._result)}};e.prototype._setResultAt=function(t,e,r,n){if(n){this._result[e]=r;var o=h(this._filterFn)(r,e);o===Pt?this._settledAt(At,e,o.error,!1):this._eachEntry(o,e,!1)}else{this._remaining--;r||(this._result[e]=Kt)}};return e}(Rt),Gt=0,Lt=void 0,Wt="undefined"!=typeof window?window:void 0,Yt=Wt||{},$t=Yt.MutationObserver||Yt.WebKitMutationObserver,zt="undefined"==typeof self&&"undefined"!=typeof process&&"[object process]"==={}.toString.call(process),Bt="undefined"!=typeof Uint8ClampedArray&&"undefined"!=typeof importScripts&&"undefined"!=typeof MessageChannel,Ht=new Array(1e3),Jt=void 0;Jt=zt?ft():$t?ht():Bt?pt():void 0===Wt&&"function"==typeof require?dt():yt();var Qt=void 0;if("object"==typeof self)Qt=self;else{if("object"!=typeof global)throw new Error("no global: `self` or `global` found");Qt=global}var Xt;gt.async=at;gt.after=function(t){return setTimeout(t,0)};var Zt=ot,te=function(t,e){return gt.async(t,e)};if("undefined"!=typeof window&&"object"==typeof window.__PROMISE_INSTRUMENTATION__){var ee=window.__PROMISE_INSTRUMENTATION__;r("instrument",!0);for(var re in ee)ee.hasOwnProperty(re)&&bt(re,ee[re])}var ne=(Xt={asap:at,cast:Zt,Promise:Mt,EventTarget:wt,all:G,allSettled:Y,race:$,hash:H,hashSettled:X,rethrow:Z,defer:tt,denodeify:U,configure:r,on:bt,off:mt,resolve:ot,reject:it,map:nt},vt(Xt,"async",te),vt(Xt,"filter",ct),Xt);t["default"]=ne;t.asap=at;t.cast=Zt;t.Promise=Mt;t.EventTarget=wt;t.all=G;t.allSettled=Y;t.race=$;t.hash=H;t.hashSettled=X;t.rethrow=Z;t.defer=tt;t.denodeify=U;t.configure=r;t.on=bt;t.off=mt;t.resolve=ot;t.reject=it;t.map=nt;t.async=te;t.filter=ct;Object.defineProperty(t,"__esModule",{value:!0})});
(function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(t.RSVP={})})(this,function(t){"use strict";function e(t){var e=t._promiseCallbacks;e||(e=t._promiseCallbacks={});return e}function r(t,e){if(2!==arguments.length)return dt[t];dt[t]=e}function n(){setTimeout(function(){for(var t=0;t<vt.length;t++){var e=vt[t],r=e.payload;r.guid=r.key+r.id;r.childGuid=r.key+r.childId;r.error&&(r.stack=r.error.stack);dt.trigger(e.name,e.payload)}vt.length=0},50)}function o(t,e,r){1===vt.push({name:t,payload:{key:e._guidKey,id:e._id,eventName:t,detail:e._result,childId:r&&r._id,label:e._label,timeStamp:Date.now(),error:dt["instrument-with-stack"]?new Error(e._label):null}})&&n()}function i(t,e){var r=this;if(t&&"object"==typeof t&&t.constructor===r)return t;var n=new r(c,e);_(n,t);return n}function s(){return new TypeError("A promises callback cannot return that same promise.")}function u(t){var e=typeof t;return null!==t&&("object"===e||"function"===e)}function c(){}function a(t){try{return t.then}catch(e){gt.error=e;return gt}}function f(){try{var t=jt;jt=null;return t.apply(this,arguments)}catch(e){gt.error=e;return gt}}function l(t){jt=t;return f}function h(t,e,r){dt.async(function(t){var n=!1,o=l(r).call(e,function(r){if(!n){n=!0;e===r?v(t,r):_(t,r)}},function(e){if(!n){n=!0;m(t,e)}},"Settle: "+(t._label||" unknown promise"));if(!n&&o===gt){n=!0;var i=gt.error;gt.error=null;m(t,i)}},t)}function p(t,e){if(e._state===bt)v(t,e._result);else if(e._state===wt){e._onError=null;m(t,e._result)}else b(e,void 0,function(r){e===r?v(t,r):_(t,r)},function(e){return m(t,e)})}function y(t,e,r){var n=e.constructor===t.constructor&&r===O&&t.constructor.resolve===i;if(n)p(t,e);else if(r===gt){var o=gt.error;gt.error=null;m(t,o)}else"function"==typeof r?h(t,e,r):v(t,e)}function _(t,e){t===e?v(t,e):u(e)?y(t,e,a(e)):v(t,e)}function d(t){t._onError&&t._onError(t._result);w(t)}function v(t,e){if(t._state===mt){t._result=e;t._state=bt;0===t._subscribers.length?dt.instrument&&o("fulfilled",t):dt.async(w,t)}}function m(t,e){if(t._state===mt){t._state=wt;t._result=e;dt.async(d,t)}}function b(t,e,r,n){var o=t._subscribers,i=o.length;t._onError=null;o[i]=e;o[i+bt]=r;o[i+wt]=n;0===i&&t._state&&dt.async(w,t)}function w(t){var e=t._subscribers,r=t._state;dt.instrument&&o(r===bt?"fulfilled":"rejected",t);if(0!==e.length){for(var n=void 0,i=void 0,s=t._result,u=0;u<e.length;u+=3){n=e[u];i=e[u+r];n?g(r,n,i,s):i(s)}t._subscribers.length=0}}function g(t,e,r,n){var o="function"==typeof r,i=void 0;i=o?l(r)(n):n;if(e._state!==mt);else if(i===e)m(e,s());else if(i===gt){var u=gt.error;gt.error=null;m(e,u)}else o?_(e,i):t===bt?v(e,i):t===wt&&m(e,i)}function j(t,e){var r=!1;try{e(function(e){if(!r){r=!0;_(t,e)}},function(e){if(!r){r=!0;m(t,e)}})}catch(n){m(t,n)}}function O(t,e,r){var n=this,i=n._state;if(i===bt&&!t||i===wt&&!e){dt.instrument&&o("chained",n,n);return n}n._onError=null;var s=new n.constructor(c,r),u=n._result;dt.instrument&&o("chained",n,s);if(i===mt)b(n,s,t,e);else{var a=i===bt?t:e;dt.async(function(){return g(i,s,a,u)})}return s}function A(t,e,r){this._remaining--;t===bt?this._result[e]={state:"fulfilled",value:r}:this._result[e]={state:"rejected",reason:r}}function E(t,e){return Array.isArray(t)?new Ot(this,t,(!0),e).promise:this.reject(new TypeError("Promise.all must be called with an array"),e)}function T(t,e){var r=this,n=new r(c,e);if(!Array.isArray(t)){m(n,new TypeError("Promise.race must be called with an array"));return n}for(var o=0;n._state===mt&&o<t.length;o++)b(r.resolve(t[o]),void 0,function(t){return _(n,t)},function(t){return m(n,t)});return n}function P(t,e){var r=this,n=new r(c,e);m(n,t);return n}function S(){throw new TypeError("You must pass a resolver function as the first argument to the promise constructor")}function R(){throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.")}function x(t,e){for(var r={},n=t.length,o=new Array(n),i=0;i<n;i++)o[i]=t[i];for(var s=0;s<e.length;s++){var u=e[s];r[u]=o[s+1]}return r}function k(t){for(var e=t.length,r=new Array(e-1),n=1;n<e;n++)r[n-1]=t[n];return r}function M(t,e){return{then:function(r,n){return t.call(e,r,n)}}}function C(t,e){var r=function(){for(var r=arguments.length,n=new Array(r+1),o=!1,i=0;i<r;++i){var s=arguments[i];if(!o){o=N(s);if(o===gt){var u=gt.error;gt.error=null;var a=new Tt(c);m(a,u);return a}o&&o!==!0&&(s=M(o,s))}n[i]=s}var f=new Tt(c);n[r]=function(t,r){t?m(f,t):void 0===e?_(f,r):e===!0?_(f,k(arguments)):Array.isArray(e)?_(f,x(arguments,e)):_(f,r)};return o?I(f,n,t,this):F(f,n,t,this)};r.__proto__=t;return r}function F(t,e,r,n){var o=l(r).apply(n,e);if(o===gt){var i=gt.error;gt.error=null;m(t,i)}return t}function I(t,e,r,n){return Tt.all(e).then(function(e){return F(t,e,r,n)})}function N(t){return null!==t&&"object"==typeof t&&(t.constructor===Tt||a(t))}function U(t,e){return Tt.all(t,e)}function V(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function D(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}});e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}function K(t,e){return Array.isArray(t)?new Pt(Tt,t,e).promise:Tt.reject(new TypeError("Promise.allSettled must be called with an array"),e)}function q(t,e){return Tt.race(t,e)}function G(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function L(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}});e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}function W(t,e){return null===t||"object"!=typeof t?Tt.reject(new TypeError("Promise.hash must be called with an object"),e):new Rt(Tt,t,e).promise}function Y(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function $(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}});e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}function z(t,e){return null===t||"object"!=typeof t?Tt.reject(new TypeError("RSVP.hashSettled must be called with an object"),e):new xt(Tt,t,(!1),e).promise}function B(t){setTimeout(function(){throw t});throw t}function H(t){var e={resolve:void 0,reject:void 0};e.promise=new Tt(function(t,r){e.resolve=t;e.reject=r},t);return e}function J(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function Q(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}});e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}function X(t,e,r){return Array.isArray(t)?"function"!=typeof e?Tt.reject(new TypeError("RSVP.map expects a function as a second argument"),r):new kt(Tt,t,e,r).promise:Tt.reject(new TypeError("RSVP.map must be called with an array"),r)}function Z(t,e){return Tt.resolve(t,e)}function tt(t,e){return Tt.reject(t,e)}function et(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function rt(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}});e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}function nt(t,e,r){return"function"!=typeof e?Tt.reject(new TypeError("RSVP.filter expects function as a second argument"),r):Tt.resolve(t,r).then(function(t){if(!Array.isArray(t))throw new TypeError("RSVP.filter must be called with an array");return new Ct(Tt,t,e,r).promise})}function ot(t,e){qt[Ft]=t;qt[Ft+1]=e;Ft+=2;2===Ft&&Gt()}function it(){var t=process.nextTick,e=process.versions.node.match(/^(?:(\d+)\.)?(?:(\d+)\.)?(\*|\d+)$/);Array.isArray(e)&&"0"===e[1]&&"10"===e[2]&&(t=setImmediate);return function(){return t(ft)}}function st(){return"undefined"!=typeof It?function(){It(ft)}:at()}function ut(){var t=0,e=new Vt(ft),r=document.createTextNode("");e.observe(r,{characterData:!0});return function(){return r.data=t=++t%2}}function ct(){var t=new MessageChannel;t.port1.onmessage=ft;return function(){return t.port2.postMessage(0)}}function at(){return function(){return setTimeout(ft,1)}}function ft(){for(var t=0;t<Ft;t+=2){var e=qt[t],r=qt[t+1];e(r);qt[t]=void 0;qt[t+1]=void 0}Ft=0}function lt(){try{var t=require,e=t("vertx");It=e.runOnLoop||e.runOnContext;return st()}catch(r){return at()}}function ht(t,e,r){e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r;return t}function pt(){dt.on.apply(dt,arguments)}function yt(){dt.off.apply(dt,arguments)}var _t={mixin:function(t){t.on=this.on;t.off=this.off;t.trigger=this.trigger;t._promiseCallbacks=void 0;return t},on:function(t,r){if("function"!=typeof r)throw new TypeError("Callback must be a function");var n=e(this),o=void 0;o=n[t];o||(o=n[t]=[]);o.indexOf(r)&&o.push(r)},off:function(t,r){var n=e(this),o=void 0,i=void 0;if(r){o=n[t];i=o.indexOf(r);i!==-1&&o.splice(i,1)}else n[t]=[]},trigger:function(t,r,n){var o=e(this),i=void 0,s=void 0;if(i=o[t])for(var u=0;u<i.length;u++){s=i[u];s(r,n)}}},dt={instrument:!1};_t.mixin(dt);var vt=[],mt=void 0,bt=1,wt=2,gt={error:null},jt=void 0,Ot=function(){function t(t,e,r,n){this._instanceConstructor=t;this.promise=new t(c,n);this._abortOnReject=r;this._isUsingOwnPromise=t===Tt;this._isUsingOwnResolve=t.resolve===i;this._init.apply(this,arguments)}t.prototype._init=function(t,e){var r=e.length||0;this.length=r;this._remaining=r;this._result=new Array(r);this._enumerate(e)};t.prototype._enumerate=function(t){for(var e=this.length,r=this.promise,n=0;r._state===mt&&n<e;n++)this._eachEntry(t[n],n,!0);this._checkFullfillment()};t.prototype._checkFullfillment=function(){0===this._remaining&&v(this.promise,this._result)};t.prototype._settleMaybeThenable=function(t,e,r){var n=this._instanceConstructor;if(this._isUsingOwnResolve){var o=a(t);if(o===O&&t._state!==mt){t._onError=null;this._settledAt(t._state,e,t._result,r)}else if("function"!=typeof o)this._settledAt(bt,e,t,r);else if(this._isUsingOwnPromise){var i=new n(c);y(i,t,o);this._willSettleAt(i,e,r)}else this._willSettleAt(new n(function(e){return e(t)}),e,r)}else this._willSettleAt(n.resolve(t),e,r)};t.prototype._eachEntry=function(t,e,r){null!==t&&"object"==typeof t?this._settleMaybeThenable(t,e,r):this._setResultAt(bt,e,t,r)};t.prototype._settledAt=function(t,e,r,n){var o=this.promise;if(o._state===mt)if(this._abortOnReject&&t===wt)m(o,r);else{this._setResultAt(t,e,r,n);this._checkFullfillment()}};t.prototype._setResultAt=function(t,e,r,n){this._remaining--;this._result[e]=r};t.prototype._willSettleAt=function(t,e,r){var n=this;b(t,void 0,function(t){return n._settledAt(bt,e,t,r)},function(t){return n._settledAt(wt,e,t,r)})};return t}(),At="rsvp_"+Date.now()+"-",Et=0,Tt=function(){function t(e,r){this._id=Et++;this._label=r;this._state=void 0;this._result=void 0;this._subscribers=[];dt.instrument&&o("created",this);if(c!==e){"function"!=typeof e&&S();this instanceof t?j(this,e):R()}}t.prototype._onError=function(t){var e=this;dt.after(function(){e._onError&&dt.trigger("error",t,e._label)})};t.prototype["catch"]=function(t,e){return this.then(void 0,t,e)};t.prototype["finally"]=function(t,e){var r=this,n=r.constructor;return r.then(function(e){return n.resolve(t()).then(function(){return e})},function(e){return n.resolve(t()).then(function(){throw e})},e)};return t}();Tt.all=E;Tt.race=T;Tt.resolve=i;Tt.reject=P;Tt.prototype._guidKey=At;Tt.prototype.then=O;var Pt=function(t){function e(e,r,n){return V(this,t.call(this,e,r,!1,n))}D(e,t);return e}(Ot);Pt.prototype._setResultAt=A;var St=Object.prototype.hasOwnProperty,Rt=function(t){function e(e,r){var n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],o=arguments[3];return G(this,t.call(this,e,r,n,o))}L(e,t);e.prototype._init=function(t,e){this._result={};this._enumerate(e);0===this._remaining&&v(this.promise,this._result)};e.prototype._enumerate=function(t){var e=this.promise,r=[];for(var n in t)St.call(t,n)&&r.push({position:n,entry:t[n]});var o=r.length;this._remaining=o;for(var i=void 0,s=0;e._state===mt&&s<o;s++){i=r[s];this._eachEntry(i.entry,i.position)}};return e}(Ot),xt=function(t){function e(e,r,n){return Y(this,t.call(this,e,r,!1,n))}$(e,t);return e}(Rt);xt.prototype._setResultAt=A;var kt=function(t){function e(e,r,n,o){return J(this,t.call(this,e,r,!0,o,n))}Q(e,t);e.prototype._init=function(t,e,r,n,o){var i=e.length||0;this.length=i;this._remaining=i;this._result=new Array(i);this._mapFn=o;this._enumerate(e)};e.prototype._setResultAt=function(t,e,r,n){if(n){var o=l(this._mapFn)(r,e);o===gt?this._settledAt(wt,e,o.error,!1):this._eachEntry(o,e,!1)}else{this._remaining--;this._result[e]=r}};return e}(Ot),Mt={},Ct=function(t){function e(e,r,n,o){return et(this,t.call(this,e,r,!0,o,n))}rt(e,t);e.prototype._init=function(t,e,r,n,o){var i=e.length||0;this.length=i;this._remaining=i;this._result=new Array(i);this._filterFn=o;this._enumerate(e)};e.prototype._checkFullfillment=function(){if(0===this._remaining){this._result=this._result.filter(function(t){return t!==Mt});v(this.promise,this._result)}};e.prototype._setResultAt=function(t,e,r,n){if(n){this._result[e]=r;var o=l(this._filterFn)(r,e);o===gt?this._settledAt(wt,e,o.error,!1):this._eachEntry(o,e,!1)}else{this._remaining--;r||(this._result[e]=Mt)}};return e}(Ot),Ft=0,It=void 0,Nt="undefined"!=typeof window?window:void 0,Ut=Nt||{},Vt=Ut.MutationObserver||Ut.WebKitMutationObserver,Dt="undefined"==typeof self&&"undefined"!=typeof process&&"[object process]"==={}.toString.call(process),Kt="undefined"!=typeof Uint8ClampedArray&&"undefined"!=typeof importScripts&&"undefined"!=typeof MessageChannel,qt=new Array(1e3),Gt=void 0;Gt=Dt?it():Vt?ut():Kt?ct():void 0===Nt&&"function"==typeof require?lt():at();var Lt;dt.async=ot;dt.after=function(t){return setTimeout(t,0)};var Wt=function(t,e){return dt.async(t,e)};if("undefined"!=typeof window&&"object"==typeof window.__PROMISE_INSTRUMENTATION__){var Yt=window.__PROMISE_INSTRUMENTATION__;r("instrument",!0);for(var $t in Yt)Yt.hasOwnProperty($t)&&pt($t,Yt[$t])}var zt=(Lt={asap:ot,Promise:Tt,EventTarget:_t,all:U,allSettled:K,race:q,hash:W,hashSettled:z,rethrow:B,defer:H,denodeify:C,configure:r,on:pt,off:yt,resolve:Z,reject:tt,map:X},ht(Lt,"async",Wt),ht(Lt,"filter",nt),Lt);t["default"]=zt;t.asap=ot;t.Promise=Tt;t.EventTarget=_t;t.all=U;t.allSettled=K;t.race=q;t.hash=W;t.hashSettled=z;t.rethrow=B;t.defer=H;t.denodeify=C;t.configure=r;t.on=pt;t.off=yt;t.resolve=Z;t.reject=tt;t.map=X;t.async=Wt;t.filter=nt;Object.defineProperty(t,"__esModule",{value:!0})});

@@ -24,3 +24,2 @@ import Promise from './rsvp/promise';

config.after = cb => setTimeout(cb, 0);
const cast = resolve;

@@ -30,7 +29,7 @@ const async = (callback, arg) => config.async(callback, arg);

function on() {
config['on'].apply(config, arguments);
config.on(...arguments);
}
function off() {
config['off'].apply(config, arguments);
config.off(...arguments);
}

@@ -49,3 +48,2 @@

import platform from './rsvp/platform';
// the default export here is for backwards compat:

@@ -55,3 +53,2 @@ // https://github.com/tildeio/rsvp.js/issues/434

asap,
cast,
Promise,

@@ -73,3 +70,3 @@ EventTarget,

map,
['async']: async, // babel seems to error if async isn't a computed prop here...
async,
filter

@@ -80,3 +77,2 @@ };

asap,
cast,
Promise,

@@ -83,0 +79,0 @@ EventTarget,

@@ -23,8 +23,4 @@ import originalThen from './then';

function ErrorObject() {
this.error = null;
}
export const TRY_CATCH_ERROR = { error: null };
const GET_THEN_ERROR = new ErrorObject();
export function getThen(promise) {

@@ -34,13 +30,11 @@ try {

} catch(error) {
GET_THEN_ERROR.error = error;
return GET_THEN_ERROR;
TRY_CATCH_ERROR.error = error;
return TRY_CATCH_ERROR;
}
}
export const TRY_CATCH_ERROR = new ErrorObject();
let tryCatchCallback;
function tryCatcher() {
try {
var target = tryCatchCallback;
let target = tryCatchCallback;
tryCatchCallback = null;

@@ -59,32 +53,32 @@ return target.apply(this, arguments);

function tryThen(then, value, fulfillmentHandler, rejectionHandler) {
try {
then.call(value, fulfillmentHandler, rejectionHandler);
} catch(e) {
return e;
}
}
function handleForeignThenable(promise, thenable, then) {
config.async(promise => {
let sealed = false;
let error = tryThen(then, thenable, value => {
if (sealed) { return; }
sealed = true;
if (thenable !== value) {
resolve(promise, value, undefined);
} else {
fulfill(promise, value);
}
}, reason => {
if (sealed) { return; }
sealed = true;
let result = tryCatch(then).call(
thenable,
value => {
if (sealed) { return; }
sealed = true;
if (thenable === value) {
fulfill(promise, value);
} else {
resolve(promise, value);
}
},
reason => {
if (sealed) { return; }
sealed = true;
reject(promise, reason);
}, 'Settle: ' + (promise._label || ' unknown promise'));
reject(promise, reason);
},
'Settle: ' + (promise._label || ' unknown promise')
);
if (!sealed && error) {
if (!sealed && result === TRY_CATCH_ERROR) {
sealed = true;
let error = TRY_CATCH_ERROR.error;
TRY_CATCH_ERROR.error = null;
reject(promise, error);
}
}, promise);

@@ -118,5 +112,5 @@ }

handleOwnThenable(promise, maybeThenable);
} else if (then === GET_THEN_ERROR) {
let error = GET_THEN_ERROR.error
GET_THEN_ERROR.error = null;
} else if (then === TRY_CATCH_ERROR) {
let error = TRY_CATCH_ERROR.error
TRY_CATCH_ERROR.error = null;
reject(promise, error);

@@ -226,4 +220,4 @@ } else if (typeof then === 'function') {

} else if (value === TRY_CATCH_ERROR) {
let error = value.error;
value.error = null; // release
let error = TRY_CATCH_ERROR.error;
TRY_CATCH_ERROR.error = null; // release
reject(promise, error);

@@ -230,0 +224,0 @@ } else if (hasCallback) {

@@ -23,3 +23,4 @@ import {

this._abortOnReject = abortOnReject;
this.isUsingOwnPromise = Constructor === OwnPromise;
this._isUsingOwnPromise = Constructor === OwnPromise;
this._isUsingOwnResolve = Constructor.resolve === ownResolve;

@@ -39,4 +40,4 @@ this._init(...arguments);

_enumerate(input) {
let length = this.length;
let promise = this.promise;
let length = this.length;
let promise = this.promise;

@@ -46,3 +47,2 @@ for (let i = 0; promise._state === PENDING && i < length; i++) {

}
this._checkFullfillment();

@@ -53,3 +53,5 @@ }

if (this._remaining === 0) {
fulfill(this.promise, this._result);
let result = this._result;
fulfill(this.promise, result);
this._result = null
}

@@ -60,5 +62,4 @@ }

let c = this._instanceConstructor;
let resolve = c.resolve;
if (resolve === ownResolve) {
if (this._isUsingOwnResolve) {
let then = getThen(entry);

@@ -71,3 +72,3 @@

this._settledAt(FULFILLED, i, entry, firstPass);
} else if (this.isUsingOwnPromise) {
} else if (this._isUsingOwnPromise) {
let promise = new c(noop);

@@ -80,3 +81,3 @@ handleMaybeThenable(promise, entry, then);

} else {
this._willSettleAt(resolve(entry), i, firstPass);
this._willSettleAt(c.resolve(entry), i, firstPass);
}

@@ -83,0 +84,0 @@ }

@@ -60,5 +60,5 @@

mixin(object) {
object['on'] = this['on'];
object['off'] = this['off'];
object['trigger'] = this['trigger'];
object.on = this.on;
object.off = this.off;
object.trigger = this.trigger;
object._promiseCallbacks = undefined;

@@ -90,6 +90,5 @@ return object;

let allCallbacks = callbacksFor(this), callbacks;
let allCallbacks = callbacksFor(this);
let callbacks = allCallbacks[eventName];
callbacks = allCallbacks[eventName];
if (!callbacks) {

@@ -99,3 +98,3 @@ callbacks = allCallbacks[eventName] = [];

if (callbacks.indexOf(callback)) {
if (callbacks.indexOf(callback) === -1) {
callbacks.push(callback);

@@ -145,3 +144,3 @@ }

off(eventName, callback) {
let allCallbacks = callbacksFor(this), callbacks, index;
let allCallbacks = callbacksFor(this);

@@ -153,7 +152,8 @@ if (!callback) {

callbacks = allCallbacks[eventName];
let callbacks = allCallbacks[eventName];
let index = callbacks.indexOf(callback);
index = callbacks.indexOf(callback);
if (index !== -1) { callbacks.splice(index, 1); }
if (index !== -1) {
callbacks.splice(index, 1);
}
},

@@ -192,9 +192,10 @@

trigger(eventName, options, label) {
let allCallbacks = callbacksFor(this), callbacks, callback;
let allCallbacks = callbacksFor(this);
if (callbacks = allCallbacks[eventName]) {
let callbacks = allCallbacks[eventName];
if (callbacks) {
// Don't cache the callbacks.length since it may grow
for (let i=0; i<callbacks.length; i++) {
let callback;
for (let i = 0; i < callbacks.length; i++) {
callback = callbacks[i];
callback(options, label);

@@ -201,0 +202,0 @@ }

import Promise from './promise';
import Enumerator from './enumerator';
import { MapEnumerator } from './map';
import {

@@ -12,22 +12,9 @@ tryCatch,

class FilterEnumerator extends Enumerator {
constructor(Constructor, entries, filterFn, label) {
super(Constructor, entries, true, label, filterFn);
}
class FilterEnumerator extends MapEnumerator {
_init(Constructor, input, bool, label, filterFn) {
let len = input.length || 0;
this.length = len;
this._remaining = len;
this._result = new Array(len);
this._filterFn = filterFn;
this._enumerate(input);
}
_checkFullfillment() {
if (this._remaining === 0) {
this._result = this._result.filter((val) => val !== EMPTY_OBJECT);
fulfill(this.promise, this._result);
if (this._remaining === 0 && this._result !== null) {
let result = this._result.filter((val) => val !== EMPTY_OBJECT);
fulfill(this.promise, result);
this._result = null;
}

@@ -39,3 +26,3 @@ }

this._result[i] = value;
let val = tryCatch(this._filterFn)(value, i);
let val = tryCatch(this._mapFn)(value, i);
if (val === TRY_CATCH_ERROR) {

@@ -142,6 +129,2 @@ this._settledAt(REJECTED, i, val.error, false);

export default function filter(promises, filterFn, label) {
if (!Array.isArray(promises) && !(promises !== null && typeof promises === 'object' && promises.then !== undefined )) {
return Promise.reject(new TypeError("RSVP.filter must be called with an array or promise"), label);
}
if (typeof filterFn !== 'function') {

@@ -153,4 +136,7 @@ return Promise.reject(new TypeError("RSVP.filter expects function as a second argument"), label);

.then(function(promises) {
if (!Array.isArray(promises)) {
throw new TypeError("RSVP.filter must be called with an array");
}
return new FilterEnumerator(Promise, promises, filterFn, label).promise;
});
}

@@ -7,3 +7,2 @@ import Promise from './promise';

import PromiseHash from './promise-hash';
import { makeSettledResult } from './enumerator';

@@ -10,0 +9,0 @@ class HashSettled extends PromiseHash {

@@ -11,3 +11,3 @@ import Promise from './promise';

class MapEnumerator extends Enumerator {
export class MapEnumerator extends Enumerator {
constructor(Constructor, entries, mapFn, label) {

@@ -14,0 +14,0 @@ super(Constructor, entries, true, label, mapFn);

@@ -5,31 +5,8 @@ import Promise from './promise';

resolve,
reject
reject,
getThen,
tryCatch,
TRY_CATCH_ERROR
} from './-internal';
function Result() {
this.value = undefined;
}
const ERROR = new Result();
const GET_THEN_ERROR = new Result();
function getThen(obj) {
try {
return obj.then;
} catch(error) {
ERROR.value= error;
return ERROR;
}
}
function tryApply(f, s, a) {
try {
f.apply(s, a);
} catch(error) {
ERROR.value = error;
return ERROR;
}
}
function makeObject(_, argumentNames) {

@@ -65,3 +42,3 @@ let obj = {};

return {
then: function(onFulFillment, onRejection) {
then(onFulFillment, onRejection) {
return then.call(promise, onFulFillment, onRejection);

@@ -202,3 +179,2 @@ }

let fn = function() {
let self = this;
let l = arguments.length;

@@ -214,5 +190,7 @@ let args = new Array(l + 1);

promiseInput = needsPromiseInput(arg);
if (promiseInput === GET_THEN_ERROR) {
if (promiseInput === TRY_CATCH_ERROR) {
let error = TRY_CATCH_ERROR.error;
TRY_CATCH_ERROR.error = null;
let p = new Promise(noop);
reject(p, GET_THEN_ERROR.value);
reject(p, error);
return p;

@@ -229,18 +207,19 @@ } else if (promiseInput && promiseInput !== true) {

args[l] = function(err, val) {
if (err)
if (err) {
reject(promise, err);
else if (options === undefined)
} else if (options === undefined) {
resolve(promise, val);
else if (options === true)
} else if (options === true) {
resolve(promise, arrayResult(arguments));
else if (Array.isArray(options))
} else if (Array.isArray(options)) {
resolve(promise, makeObject(arguments, options));
else
} else {
resolve(promise, val);
}
};
if (promiseInput) {
return handlePromiseInput(promise, args, nodeFunc, self);
return handlePromiseInput(promise, args, nodeFunc, this);
} else {
return handleValueInput(promise, args, nodeFunc, self);
return handleValueInput(promise, args, nodeFunc, this);
}

@@ -255,5 +234,7 @@ };

function handleValueInput(promise, args, nodeFunc, self) {
let result = tryApply(nodeFunc, self, args);
if (result === ERROR) {
reject(promise, result.value);
let result = tryCatch(nodeFunc).apply(self, args);
if (result === TRY_CATCH_ERROR) {
let error = TRY_CATCH_ERROR.error;
TRY_CATCH_ERROR.error = null;
reject(promise, error);
}

@@ -264,13 +245,8 @@ return promise;

function handlePromiseInput(promise, args, nodeFunc, self){
return Promise.all(args).then(args => {
let result = tryApply(nodeFunc, self, args);
if (result === ERROR) {
reject(promise, result.value);
}
return promise;
});
return Promise.all(args)
.then(args => handleValueInput(promise, args, nodeFunc, self));
}
function needsPromiseInput(arg) {
if (arg && typeof arg === 'object') {
if (arg !== null && typeof arg === 'object') {
if (arg.constructor === Promise) {

@@ -277,0 +253,0 @@ return true;

@@ -8,4 +8,2 @@ import Enumerator from './enumerator';

const hasOwnProperty = Object.prototype.hasOwnProperty;
export default class PromiseHash extends Enumerator {

@@ -18,31 +16,21 @@ constructor(Constructor, object, abortOnReject = true, label) {

this._result = {};
this._enumerate(object);
if (this._remaining === 0) {
fulfill(this.promise, this._result);
}
}
_enumerate(input) {
let promise = this.promise;
let results = [];
let keys = Object.keys(input);
for (let key in input) {
if (hasOwnProperty.call(input, key)) {
results.push({
position: key,
entry: input[key]
});
}
}
let length = results.length;
let length = keys.length;
let promise = this.promise;
this._remaining = length;
let result;
let key, val;
for (let i = 0; promise._state === PENDING && i < length; i++) {
result = results[i];
this._eachEntry(result.entry, result.position);
key = keys[i];
val = input[key];
this._eachEntry(val, key, true);
}
this._checkFullfillment();
}
}

@@ -235,3 +235,2 @@ import { config } from './config';

Promise.cast = Resolve; // deprecated
Promise.all = all;

@@ -238,0 +237,0 @@ Promise.race = race;

{
"name": "rsvp",
"namespace": "RSVP",
"version": "4.7.0",
"version": "4.8.0",
"description": "A lightweight library that provides tools for organizing asynchronous code",

@@ -32,13 +32,12 @@ "main": "dist/rsvp.js",

"broccoli-concat": "^3.2.2",
"broccoli-funnel": "2.0.1",
"broccoli-merge-trees": "^2.0.0",
"broccoli-rollup": "^1.3.0",
"broccoli-rollup": "2.0.0",
"broccoli-stew": "^1.5.0",
"broccoli-uglify-js": "^0.2.0",
"broccoli-watchify": "1.0.1",
"ember-cli": "2.13.2",
"ember-cli-dependency-checker": "2.0.0",
"ember-publisher": "0.0.7",
"git-repo-version": "0.4.1",
"json3": "^3.3.2",
"mocha": "3.4.2",
"ember-cli": "2.18.0",
"ember-cli-dependency-checker": "2.1.0",
"git-repo-version": "1.0.1",
"mocha": "4.1.0",
"promises-aplus-tests-phantom": "^2.1.0-revise"

@@ -48,9 +47,7 @@ },

"build": "ember build --environment production",
"build:production": "ember build --env production",
"start": "ember s",
"test": "ember test",
"test:server": "ember test --server",
"test:node": "ember build && mocha ./dist/test/browserify",
"prepublish": "ember build --environment production",
"lint": "jshint lib"
"test:node": "ember test --launch Mocha",
"test:browser": "ember test --launch PhantomJS"
},

@@ -57,0 +54,0 @@ "repository": {

# RSVP.js [![Build Status](https://secure.travis-ci.org/tildeio/rsvp.js.svg?branch=master)](http://travis-ci.org/tildeio/rsvp.js) [![Inline docs](http://inch-ci.org/github/tildeio/rsvp.js.svg?branch=master)](http://inch-ci.org/github/tildeio/rsvp.js)
RSVP.js provides simple tools for organizing asynchronous code.

@@ -7,20 +6,29 @@

It works in node and the browser (IE6+, all the popular evergreen ones).
It works in node and the browser (IE9+, all the popular evergreen ones).
## downloads
- [rsvp-latest](http://rsvpjs-builds.s3.amazonaws.com/rsvp-latest.js)
- [rsvp-latest (minified)](http://rsvpjs-builds.s3.amazonaws.com/rsvp-latest.min.js)
- rsvp ([latest](https://cdn.jsdelivr.net/npm/rsvp/dist/rsvp.js) | [4.x](https://cdn.jsdelivr.net/npm/rsvp@4/dist/rsvp.js))
- rsvp minified ([latest](https://cdn.jsdelivr.net/npm/rsvp/dist/rsvp.min.js) | [4.x](https://cdn.jsdelivr.net/npm/rsvp@4/dist/rsvp.min.js))
## Promises
## CDN
Although RSVP is ES6 compliant, it does bring along some extra toys. If you would prefer a strict ES6 subset, I would suggest checking out our sibling project https://github.com/stefanpenner/es6-promise, It is RSVP but stripped down to the ES6 spec features.
```html
<script src="https://cdn.jsdelivr.net/npm/rsvp@4/dist/rsvp.min.js"></script>
```
## Bower
## Promises
`bower install -S rsvp`
Although RSVP is ES6 compliant, it does bring along some extra toys. If you
would prefer a strict ES6 subset, I would suggest checking out our sibling
project https://github.com/stefanpenner/es6-promise, It is RSVP but stripped
down to the ES6 spec features.
## NPM
## Node
`npm install --save rsvp`
```sh
yarn add --save rsvp
# or ...
npm install --save rsvp
```

@@ -35,7 +43,7 @@ `RSVP.Promise` is an implementation of

It is compatible with [TaskJS](http://taskjs.org/), a library by Dave
Herman of Mozilla that uses ES6 generators to allow you to write
synchronous code with promises. It currently works in Firefox, and will
work in any browser that adds support for ES6 generators. See the
section below on TaskJS for more information.
It is compatible with [TaskJS](https://github.com/mozilla/task.js), a library
by Dave Herman of Mozilla that uses ES6 generators to allow you to write
synchronous code with promises. It currently works in Firefox, and will work in
any browser that adds support for ES6 generators. See the section below on
TaskJS for more information.

@@ -61,4 +69,4 @@ ### Basic Usage

Once a promise has been resolved or rejected, it cannot be resolved or
rejected again.
Once a promise has been resolved or rejected, it cannot be resolved or rejected
again.

@@ -97,8 +105,7 @@ Here is an example of a simple XHR2 wrapper written using RSVP.js:

One of the really awesome features of Promises/A+ promises are that they
can be chained together. In other words, the return value of the first
One of the really awesome features of Promises/A+ promises are that they can be
chained together. In other words, the return value of the first
resolve handler will be passed to the second resolve handler.
If you return a regular value, it will be passed, as is, to the next
handler.
If you return a regular value, it will be passed, as is, to the next handler.

@@ -113,4 +120,3 @@ ```javascript

The really awesome part comes when you return a promise from the first
handler:
The really awesome part comes when you return a promise from the first handler:

@@ -126,5 +132,5 @@ ```javascript

This allows you to flatten out nested callbacks, and is the main feature
of promises that prevents "rightward drift" in programs with a lot of
asynchronous code.
This allows you to flatten out nested callbacks, and is the main feature of
promises that prevents "rightward drift" in programs with a lot of asynchronous
code.

@@ -142,5 +148,5 @@ Errors also propagate:

You can use this to emulate `try/catch` logic in synchronous code.
Simply chain as many resolve callbacks as a you want, and add a failure
handler at the end to catch errors.
You can use this to emulate `try/catch` logic in synchronous code. Simply chain
as many resolve callbacks as you want, and add a failure handler at the end to
catch errors.

@@ -159,10 +165,10 @@ ```javascript

There are times when dealing with promises that it seems like any errors
are being 'swallowed', and not properly raised. This makes it extremely
difficult to track down where a given issue is coming from. Thankfully,
`RSVP` has a solution for this problem built in.
There are times when dealing with promises that it seems like any errors are
being 'swallowed', and not properly raised. This makes it extremely difficult
to track down where a given issue is coming from. Thankfully, `RSVP` has a
solution for this problem built in.
You can register functions to be called when an uncaught error occurs
within your promises. These callback functions can be anything, but a common
practice is to call `console.assert` to dump the error to the console.
You can register functions to be called when an uncaught error occurs within
your promises. These callback functions can be anything, but a common practice
is to call `console.assert` to dump the error to the console.

@@ -189,4 +195,4 @@ ```javascript

**NOTE:** promises do allow for errors to be handled asynchronously, so
this callback may result in false positives.
**NOTE:** promises do allow for errors to be handled asynchronously, so this
callback may result in false positives.

@@ -209,7 +215,6 @@ ## Finally

Sometimes you might want to work with many promises at once. If you
pass an array of promises to the `all()` method it will return a new
promise that will be fulfilled when all of the promises in the array
have been fulfilled; or rejected immediately if any promise in the array
is rejected.
Sometimes you might want to work with many promises at once. If you pass an
array of promises to the `all()` method it will return a new promise that will
be fulfilled when all of the promises in the array have been fulfilled; or
rejected immediately if any promise in the array is rejected.

@@ -231,4 +236,4 @@ ```javascript

If you need to reference many promises at once (like `all()`), but would like
to avoid encoding the actual promise order you can use `hash()`. If you pass
an object literal (where the values are promises) to the `hash()` method it will
to avoid encoding the actual promise order you can use `hash()`. If you pass an
object literal (where the values are promises) to the `hash()` method it will
return a new promise that will be fulfilled when all of the promises have been

@@ -238,5 +243,5 @@ fulfilled; or rejected immediately if any promise is rejected.

The key difference to the `all()` function is that both the fulfillment value
and the argument to the `hash()` function are object literals. This allows
you to simply reference the results directly off the returned object without
having to remember the initial order like you would with `all()`.
and the argument to the `hash()` function are object literals. This allows you
to simply reference the results directly off the returned object without having
to remember the initial order like you would with `all()`.

@@ -259,8 +264,8 @@ ```javascript

rejecting immediately if any promise is rejected, as with `all()` or `hash()`,
you want to be able to inspect the results of all your promises, whether
they fulfill or reject. For this purpose, you can use `allSettled()` and
`hashSettled()`. These work exactly like `all()` and `hash()`, except that
they fulfill with an array or hash (respectively) of the constituent promises'
result states. Each state object will either indicate fulfillment or
rejection, and provide the corresponding value or reason. The states will take
you want to be able to inspect the results of all your promises, whether they
fulfill or reject. For this purpose, you can use `allSettled()` and
`hashSettled()`. These work exactly like `all()` and `hash()`, except that they
fulfill with an array or hash (respectively) of the constituent promises'
result states. Each state object will either indicate fulfillment or rejection,
and provide the corresponding value or reason. The states will take
one of the following formats:

@@ -281,4 +286,5 @@

Sometimes one needs to create a deferred object, without immediately specifying
how it will be resolved. These deferred objects are essentially a wrapper around
a promise, whilst providing late access to the `resolve()` and `reject()` methods.
how it will be resolved. These deferred objects are essentially a wrapper
around a promise, whilst providing late access to the `resolve()` and
`reject()` methods.

@@ -298,3 +304,3 @@ A deferred object has this form: `{ promise, resolve(x), reject(r) }`.

The [TaskJS](http://taskjs.org/) library makes it possible to take
The [TaskJS](https://github.com/mozilla/task.js) library makes it possible to take
promises-oriented code and make it synchronous using ES6 generators.

@@ -329,7 +335,7 @@

In the above example, `function *` is new syntax in ES6 for
[generators](http://wiki.ecmascript.org/doku.php?id=harmony:generators).
Inside a generator, `yield` pauses the generator, returning control to
the function that invoked the generator. In this case, the invoker is a
special function that understands the semantics of Promises/A, and will
automatically resume the generator as soon as the promise is resolved.
[generators](http://wiki.ecmascript.org/doku.php?id=harmony:generators). Inside
a generator, `yield` pauses the generator, returning control to the function
that invoked the generator. In this case, the invoker is a special function
that understands the semantics of Promises/A, and will automatically resume the
generator as soon as the promise is resolved.

@@ -336,0 +342,0 @@ The cool thing here is the same promises that work with current

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc