ig-types 6.24.14 → 6.24.15

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 +35 -2
  2. package/package.json +1 -1
package/Promise.js CHANGED
@@ -817,6 +817,36 @@ object.Constructor('IterablePromise', Promise, {
817
817
  //---------------------------------------------------------------------
818
818
  // XXX EXPEREMENTAL/HACK...
819
819
 
820
+ // This like IterablePromise but guarantees handler execution in order
821
+ // element occurrence.
822
+ //
823
+ // For comparison:
824
+ // Promise.all([ .. ]).then(func)
825
+ // - func is called on element list
826
+ // - func is called when all the elements are resolved
827
+ // Promise.iter([ .. ]).iter(func)
828
+ // - func per element
829
+ // - func is called when an element is resolved/ready
830
+ // in any order
831
+ // Promise.seqiter([ .. ]).iter(func)
832
+ // - func per element
833
+ // - func is called when an element is resolved/ready
834
+ // and when all elements before it are handled
835
+ //
836
+ // NOTE: that here a promise will block handling of later promises even
837
+ // if they are resolved before it.
838
+ //
839
+ // XXX BUG:
840
+ // await Promise.seqiter([
841
+ // 1,
842
+ // Promise.resolve(2),
843
+ // Promise.resolve(3)
844
+ // Promise.resolve(4)
845
+ // Promise.resolve(5)
846
+ // ])
847
+ // -> [ 1, 2, [3], [[4]], [[[5]]] ]
848
+ // looks like we need to flatten things...
849
+ // XXX FIXED but need more testing...
820
850
  // XXX not sure if this is a viable strategy....
821
851
  var IterableSequentialPromise =
822
852
  module.IterableSequentialPromise =
@@ -834,14 +864,17 @@ object.Constructor('IterableSequentialPromise', IterablePromise, {
834
864
  && i < list.length-1){
835
865
  res.push(e
836
866
  .then(function(e){
837
- return seqiter([...e, ...list.slice(i+1)]) }))
867
+ return seqiter([...e, ...list.slice(i+1)])
868
+ .flat() }))
838
869
  break }
839
870
  res.push(e) }
840
871
  return res }
841
872
 
842
873
  // NOTE: we are not handling the list here...
843
874
  list = object.parentCall(IterableSequentialPromise.prototype.__pack, this, list)
844
-
875
+ list = list instanceof SyncPromise ?
876
+ list.sync()
877
+ : list
845
878
  list = list instanceof Array ?
846
879
  repack(list)
847
880
  // XXX check for .then(..) instead???
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ig-types",
3
- "version": "6.24.14",
3
+ "version": "6.24.15",
4
4
  "description": "Generic JavaScript types and type extensions...",
5
5
  "main": "main.js",
6
6
  "scripts": {