forked from Esri/arcgis-js-api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
promiseList.js
25 lines (24 loc) · 1.42 KB
/
promiseList.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
// COPYRIGHT © 201 Esri
//
// All rights reserved under the copyright laws of the United States
// and applicable international laws, treaties, and conventions.
//
// This material is licensed for use under the Esri Master License
// Agreement (MLA), and is bound by the terms of that agreement.
// You may redistribute and use this code without modification,
// provided you adhere to the terms of the MLA and include this
// copyright notice.
//
// See use restrictions at http://www.esri.com/legal/pdfs/mla_e204_e300/english
//
// For additional information, contact:
// Environmental Systems Research Institute, Inc.
// Attn: Contracts and Legal Services Department
// 380 New York Street
// Redlands, California, USA 92373
// USA
//
// email: [email protected]
//
// See http://js.arcgis.com/3.34/esri/copyright.txt for details.
define(["dojo/_base/array","dojo/Deferred","dojo/when"],(function(e,r,n){"use strict";var o=e.forEach;return function(e){var i,t,s;e instanceof Array?t=e:e&&"object"==typeof e&&(i=e);var f=[];if(i){for(var u in t=[],i)Object.hasOwnProperty.call(i,u)&&(f.push(u),t.push(i[u]));s={}}else t&&(s=[]);if(!t||!t.length)return(new r).resolve(s);var a=new r;a.promise.always((function(){s=f=null}));var l=t.length;function c(e,r){s[r]=e,a.progress([e,r]),0==--l&&a.resolve(s)}return o(t,(function(e,r){i||f.push(r),n(e,(function(e){a.isFulfilled()||c(e,f[r])}),(function(e){a.isFulfilled()||c(e,f[r])}))})),a.promise}}));