ig-types 6.13.6 → 6.13.7

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 +9 -44
  2. package/package.json +1 -1
package/Promise.js CHANGED
@@ -163,8 +163,6 @@ object.Constructor('IterablePromise', Promise, {
163
163
  // .includes(..)
164
164
  // .some(..) / .every(..)
165
165
  // .sort(..)
166
- //
167
- // XXX should these support STOP???
168
166
  map: function(func){
169
167
  return this.constructor(this,
170
168
  function(e){
@@ -188,11 +186,9 @@ object.Constructor('IterablePromise', Promise, {
188
186
  // what the user reduces to...
189
187
  // XXX we could look at the initial state though...
190
188
  // NOTE: the items can be handled out of order because the nested
191
- // promises can resolve in any order.
192
- // XXX doc how to go around this...
189
+ // promises can resolve in any order...
193
190
  // NOTE: since order of execution can not be guaranteed there is no
194
191
  // point in implementing .reduceRight(..)
195
- // XXX should func be able to return a promise???
196
192
  reduce: function(func, res){
197
193
  return this.constructor(this,
198
194
  function(e){
@@ -200,14 +196,6 @@ object.Constructor('IterablePromise', Promise, {
200
196
  return [] })
201
197
  .then(function(){
202
198
  return res }) },
203
- /* // XXX since order of execution is not fixed there is no point in
204
- // adding this.
205
- reduceRight: function(func, res){
206
- return this
207
- .reverse()
208
- .reduce(...arguments)
209
- .reverse() },
210
- //*/
211
199
  flat: function(depth=1){
212
200
  return this.constructor(this,
213
201
  function(e){
@@ -256,7 +244,7 @@ object.Constructor('IterablePromise', Promise, {
256
244
  [cur, ...other]
257
245
  : other instanceof Promise ?
258
246
  [...cur, other]
259
- : cur.concat(other),
247
+ : [...cur, ...other],
260
248
  'raw') },
261
249
  push: function(elem){
262
250
  return this.concat([elem]) },
@@ -311,14 +299,14 @@ object.Constructor('IterablePromise', Promise, {
311
299
  // -> []
312
300
  //
313
301
  //
314
- // NOTE: element index is unknowable untill the full list is expanded
302
+ // NOTE: element index is unknowable until the full list is expanded
315
303
  // as handler(..)'s return value can expand to any number of
316
304
  // items...
317
305
  // XXX we can make the index a promise, then if the client needs
318
306
  // the value they can wait for it...
319
307
  //
320
308
  //
321
- // Spectial cases usefull for extending this constructor...
309
+ // Special cases useful for extending this constructor...
322
310
  //
323
311
  // Set raw .__list without any pre-processing...
324
312
  // Promise.iter([ .. ], 'raw')
@@ -329,45 +317,25 @@ object.Constructor('IterablePromise', Promise, {
329
317
  // -> iterable-promise
330
318
  //
331
319
  //
332
- // XXX if list is an iterator, can we fill this async???
333
320
  // XXX iterator/generator as input:
334
321
  // - do we unwind here or externally?
335
322
  // ...feels like with the generator external unwinding is
336
323
  // needed...
337
- // XXX would be nice to support trowing STOP...
324
+ // XXX would be nice to support throwing STOP...
338
325
  // - this is more complicated than simply suing .smap(..) instead
339
326
  // of .map(..) because the list can contain async promises...
340
327
  // ...would need to wrap each .then(..) call in try-catch and
341
328
  // manually handle the stop...
342
329
  // - another issue here is that the stop would happen in order of
343
330
  // execution and not order of elements...
344
- // XXX DOC:
345
- // inputs:
346
- // - Chaining -- list instanceof IterablePromise
347
- // After all the promises resolve .flat() should
348
- // turn this into the input list.
349
- // For this to work we'll need to at least wrap all
350
- // arrays and promise results in arrays.
351
- // (currently each value is wrapped)
352
- // -> __list
353
- // - promise (value | array)
354
- // - array of:
355
- // - array
356
- // - value
357
- // - promise (value | array)
358
- // - New
359
- // - promise (value | array)
360
- // - value (non-array)
361
- // - array of:
362
- // - value
363
- // - promise (value)
331
+ // XXX how do we handle errors???
364
332
  __new__: function(_, list, handler){
365
333
  // instance...
366
334
  var promise
367
335
  var obj = Reflect.construct(
368
336
  IterablePromise.__proto__,
369
337
  [function(resolve, reject){
370
- // NOTE: this is here for Promise compatibilty...
338
+ // NOTE: this is here for Promise compatibility...
371
339
  if(typeof(list) == 'function'){
372
340
  return list.call(this, ...arguments) }
373
341
  // initial reject...
@@ -376,17 +344,17 @@ object.Constructor('IterablePromise', Promise, {
376
344
  promise = {resolve, reject} }],
377
345
  IterablePromise)
378
346
 
347
+ // new instance...
379
348
  if(promise){
349
+ // handle/pack input data...
380
350
  if(handler != 'raw'){
381
351
  list = list instanceof IterablePromise ?
382
352
  this.__handle(list.__list, handler)
383
353
  : this.__pack(list, handler) }
384
-
385
354
  Object.defineProperty(obj, '__list', {
386
355
  value: list,
387
356
  enumerable: false,
388
357
  })
389
-
390
358
  // handle promise state...
391
359
  this.__unpack(list)
392
360
  .then(function(list){
@@ -591,13 +559,10 @@ object.Mixin('PromiseMixin', 'soft', {
591
559
  PromiseMixin(Promise)
592
560
 
593
561
 
594
- // XXX EXPEREMENTAL...
595
562
  var PromiseProtoMixin =
596
563
  module.PromiseProtoMixin =
597
564
  object.Mixin('PromiseProtoMixin', 'soft', {
598
565
  as: ProxyPromise,
599
-
600
- // XXX
601
566
  iter: function(handler){
602
567
  return IterablePromise(this, handler) },
603
568
  })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ig-types",
3
- "version": "6.13.6",
3
+ "version": "6.13.7",
4
4
  "description": "Generic JavaScript types and type extensions...",
5
5
  "main": "main.js",
6
6
  "scripts": {