ig-types 6.26.0 → 6.26.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Promise.js +16 -4
- package/package.json +1 -1
package/Promise.js
CHANGED
|
@@ -1359,22 +1359,34 @@ object.Mixin('PromiseMixin', 'soft', {
|
|
|
1359
1359
|
|
|
1360
1360
|
sync: SyncPromise,
|
|
1361
1361
|
|
|
1362
|
+
//
|
|
1363
|
+
// .awaitOrRun(<data>, .. , <func>)
|
|
1364
|
+
// .awaitOrRun(<data>, .. , <func>, <onerror>)
|
|
1365
|
+
// .awaitOrRun(<data>, .. , <func>, null)
|
|
1366
|
+
// -> <value>
|
|
1367
|
+
// -> <promise>
|
|
1368
|
+
//
|
|
1362
1369
|
// XXX should this be implemented via SyncPromise???
|
|
1363
1370
|
// XXX not sure if we need to expand async generators...
|
|
1364
1371
|
// (update README if this changes)
|
|
1372
|
+
// XXX add ability to skip array internals checking...
|
|
1365
1373
|
awaitOrRun: function(data, func, error){
|
|
1374
|
+
var mode = 'deep'
|
|
1366
1375
|
data = [...arguments]
|
|
1367
1376
|
func = data.pop()
|
|
1368
|
-
if(
|
|
1377
|
+
if(data.length > 1
|
|
1378
|
+
&& (typeof(data.at(-1)) == 'function'
|
|
1379
|
+
|| func == null)){
|
|
1369
1380
|
error = func
|
|
1370
1381
|
func = data.pop() }
|
|
1371
1382
|
error = error ?
|
|
1372
1383
|
[error]
|
|
1373
1384
|
: []
|
|
1374
1385
|
// check if we need to await...
|
|
1375
|
-
return
|
|
1376
|
-
|
|
1377
|
-
|
|
1386
|
+
return (mode == 'deep'
|
|
1387
|
+
&& data.reduce(function(res, e){
|
|
1388
|
+
return res
|
|
1389
|
+
|| e instanceof Promise }, false)) ?
|
|
1378
1390
|
// NOTE: we will not reach this on empty data...
|
|
1379
1391
|
(data.length > 1 ?
|
|
1380
1392
|
Promise.all(data)
|