ig-types 6.26.0 → 6.26.2

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.
Files changed (2) hide show
  1. package/Promise.js +17 -4
  2. package/package.json +1 -1
package/Promise.js CHANGED
@@ -416,6 +416,7 @@ object.Constructor('IterablePromise', Promise, {
416
416
  //
417
417
  // pack and oprionally transform/handle an array (sync)...
418
418
  __pack: function(list, handler=undefined, onerror=undefined){
419
+ var that = this
419
420
  // handle iterable promise...
420
421
  if(list instanceof IterablePromise){
421
422
  return this.__handle(list.__packed, handler, onerror) }
@@ -1359,22 +1360,34 @@ object.Mixin('PromiseMixin', 'soft', {
1359
1360
 
1360
1361
  sync: SyncPromise,
1361
1362
 
1363
+ //
1364
+ // .awaitOrRun(<data>, .. , <func>)
1365
+ // .awaitOrRun(<data>, .. , <func>, <onerror>)
1366
+ // .awaitOrRun(<data>, .. , <func>, null)
1367
+ // -> <value>
1368
+ // -> <promise>
1369
+ //
1362
1370
  // XXX should this be implemented via SyncPromise???
1363
1371
  // XXX not sure if we need to expand async generators...
1364
1372
  // (update README if this changes)
1373
+ // XXX add ability to skip array internals checking...
1365
1374
  awaitOrRun: function(data, func, error){
1375
+ var mode = 'deep'
1366
1376
  data = [...arguments]
1367
1377
  func = data.pop()
1368
- if(typeof(data.at(-1)) == 'function'){
1378
+ if(data.length > 1
1379
+ && (typeof(data.at(-1)) == 'function'
1380
+ || func == null)){
1369
1381
  error = func
1370
1382
  func = data.pop() }
1371
1383
  error = error ?
1372
1384
  [error]
1373
1385
  : []
1374
1386
  // check if we need to await...
1375
- return data.reduce(function(res, e){
1376
- return res
1377
- || e instanceof Promise }, false) ?
1387
+ return (mode == 'deep'
1388
+ && data.reduce(function(res, e){
1389
+ return res
1390
+ || e instanceof Promise }, false)) ?
1378
1391
  // NOTE: we will not reach this on empty data...
1379
1392
  (data.length > 1 ?
1380
1393
  Promise.all(data)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ig-types",
3
- "version": "6.26.0",
3
+ "version": "6.26.2",
4
4
  "description": "Generic JavaScript types and type extensions...",
5
5
  "main": "main.js",
6
6
  "scripts": {