2020-10-07 03:53:10 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								# types.js
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-05-26 11:57:21 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Library of JavaScript type extensions, types and utilities.
							 
						 
					
						
							
								
									
										
										
										
											2020-10-07 03:53:10 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								-  [types.js ](#typesjs ) 
						 
					
						
							
								
									
										
										
										
											2020-10-07 07:33:58 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  -  [Installation ](#installation )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  -  [Basic usage ](#basic-usage )
							 
						 
					
						
							
								
									
										
										
										
											2020-11-18 06:09:43 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  -  [`Object` ](#object )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    -  [`Object.deepKeys(..)` ](#objectdeepkeys )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    -  [`Object.copy(..)` (EXPERIMENTAL) ](#objectcopy-experimental )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    -  [`Object.flatCopy(..)` ](#objectflatcopy )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    -  [`Object.match(..)` ](#objectmatch )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    -  [`Object.matchPartial(..)` ](#objectmatchpartial )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    -  [`<object>.run(..)` ](#objectrun )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    -  [`Object.sort(..)` ](#objectsort )
							 
						 
					
						
							
								
									
										
										
										
											2022-07-07 11:39:08 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  -  [`Function` ](#function )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    -  [`func.AsyncFunction` ](#funcasyncfunction )
							 
						 
					
						
							
								
									
										
										
										
											2020-11-18 06:09:43 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  -  [`Array` ](#array )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    -  [`<array>.first(..)` / `<array>.last(..)` ](#arrayfirst--arraylast )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    -  [`<array>.rol(..)` ](#arrayrol )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    -  [`<array>.compact()` ](#arraycompact )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    -  [`<array>.len` ](#arraylen )
							 
						 
					
						
							
								
									
										
										
										
											2020-12-08 01:53:40 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    -  [`<array>.unique()` / `<array>.tailUnique()` ](#arrayunique--arraytailunique )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    -  [`<array>.trim()` / `<array>.trimStart()` / `<array>.trimEnd()` ](#arraytrim--arraytrimstart--arraytrimend )
							 
						 
					
						
							
								
									
										
										
										
											2020-11-18 06:09:43 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    -  [`<array>.cmp(..)` ](#arraycmp )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    -  [`<array>.setCmp(..)` ](#arraysetcmp )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    -  [`<array>.sortAs(..)` ](#arraysortas )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    -  [`<array>.inplaceSortAs(..)` ](#arrayinplacesortas )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    -  [`<array>.toKeys(..)` ](#arraytokeys )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    -  [`<array>.toMap(..)` ](#arraytomap )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    -  [`Array.zip(..)` / `<array>.zip(..)` ](#arrayzip--arrayzip )
							 
						 
					
						
							
								
									
										
										
										
											2020-11-18 06:59:56 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    -  [`Array.iter(..)` / `<array>.iter()` ](#arrayiter--arrayiter )
							 
						 
					
						
							
								
									
										
										
										
											2020-11-07 03:19:52 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    -  [Abortable `Array` iteration ](#abortable-array-iteration )
							 
						 
					
						
							
								
									
										
										
										
											2020-11-23 22:27:30 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      -  [`array.STOP` / `array.STOP(..)` ](#arraystop--arraystop )
							 
						 
					
						
							
								
									
										
										
										
											2020-11-07 03:19:52 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      -  [`<array>.smap(..)` / `<array>.sfilter(..)` / `<array>.sreduce(..)` / `<array>.sforEach(..)` ](#arraysmap--arraysfilter--arraysreduce--arraysforeach )
							 
						 
					
						
							
								
									
										
										
										
											2020-10-11 03:09:48 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    -  [Large `Array` iteration (chunked) ](#large-array-iteration-chunked )
							 
						 
					
						
							
								
									
										
										
										
											2020-11-23 22:27:30 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      -  [`array.STOP` / `array.STOP(..)` ](#arraystop--arraystop-1 )
							 
						 
					
						
							
								
									
										
										
										
											2020-10-11 03:09:48 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      -  [`<array>.CHUNK_SIZE` ](#arraychunk_size )
							 
						 
					
						
							
								
									
										
										
										
											2020-12-08 01:53:40 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      -  [`<array>.mapChunks(..)` / `<array>.filterChunks(..)` / `<array>.reduceChunks(..)` ](#arraymapchunks--arrayfilterchunks--arrayreducechunks )
							 
						 
					
						
							
								
									
										
										
										
											2020-11-18 06:09:43 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  -  [`Map` ](#map )
							 
						 
					
						
							
								
									
										
										
										
											2021-06-08 18:43:02 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    -  [`<map>.replaceKey(..)` ](#mapreplacekey )
							 
						 
					
						
							
								
									
										
										
										
											2020-11-18 06:09:43 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    -  [`<map>.sort(..)` ](#mapsort )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  -  [`Set` ](#set )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    -  [`<set>.unite(..)` ](#setunite )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    -  [`<set>.intersect(..)` ](#setintersect )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    -  [`<set>.subtract(..)` ](#setsubtract )
							 
						 
					
						
							
								
									
										
										
										
											2021-06-13 13:59:20 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    -  [`<set>.splice(..)` ](#setsplice )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    -  [`<set>.replace(..)` ](#setreplace )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    -  [`<set>.replaceAt(..)` ](#setreplaceat )
							 
						 
					
						
							
								
									
										
										
										
											2020-11-18 06:09:43 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    -  [`<set>.sort(..)` ](#setsort )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  -  [`Date` ](#date )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    -  [`Date.timeStamp(..)` ](#datetimestamp )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    -  [`Date.fromTimeStamp(..)` ](#datefromtimestamp )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    -  [`Date.str2ms(..)` ](#datestr2ms )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    -  [`<date>.toShortDate(..)` ](#datetoshortdate )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    -  [`<date>.getTimeStamp(..)` ](#dategettimestamp )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    -  [`<date>.setTimeStamp(..)` ](#datesettimestamp )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  -  [`String` ](#string )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    -  [`<string>.capitalize()` ](#stringcapitalize )
							 
						 
					
						
							
								
									
										
										
										
											2020-12-17 18:55:28 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    -  [`<string>.indent(..)` ](#stringindent )
							 
						 
					
						
							
								
									
										
										
										
											2020-11-18 06:09:43 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  -  [`RegExp` ](#regexp )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    -  [`RegExp.quoteRegExp(..)` ](#regexpquoteregexp )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  -  [`Promise` ](#promise )
							 
						 
					
						
							
								
									
										
										
										
											2021-04-06 14:27:48 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    -  [Interactive promises ](#interactive-promises )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      -  [`Promise.interactive(..)` ](#promiseinteractive )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      -  [`<promise-inter>.send(..)` ](#promise-intersend )
							 
						 
					
						
							
								
									
										
										
										
											2021-04-07 14:47:25 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      -  [`<promise-inter>.then(..)` ](#promise-interthen )
							 
						 
					
						
							
								
									
										
										
										
											2020-11-18 06:09:43 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    -  [Cooperative promises ](#cooperative-promises )
							 
						 
					
						
							
								
									
										
										
										
											2021-04-07 14:47:25 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      -  [`Promise.cooperative()` ](#promisecooperative )
							 
						 
					
						
							
								
									
										
										
										
											2020-11-18 06:09:43 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      -  [`<promise-coop>.set(..)` ](#promise-coopset )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      -  [`<promise-coop>.isSet` ](#promise-coopisset )
							 
						 
					
						
							
								
									
										
										
										
											2021-04-07 14:47:25 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      -  [`<promise-coop>.then(..)` ](#promise-coopthen )
							 
						 
					
						
							
								
									
										
										
										
											2020-11-18 06:09:43 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    -  [Promise iteration ](#promise-iteration )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      -  [`Promise.iter(..)` / `promise.IterablePromise(..)` ](#promiseiter--promiseiterablepromise )
							 
						 
					
						
							
								
									
										
										
										
											2022-06-02 12:05:37 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      -  [`<promise>.iter()` ](#promiseiter )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      -  [`<promise-iter>.iter()` ](#promise-iteriter )
							 
						 
					
						
							
								
									
										
										
										
											2020-11-18 06:09:43 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      -  [`<promise-iter>.map(..)` / `<promise-iter>.filter(..)` / `<promise-iter>.reduce(..)` ](#promise-itermap--promise-iterfilter--promise-iterreduce )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      -  [`<promise-iter>.flat(..)` ](#promise-iterflat )
							 
						 
					
						
							
								
									
										
										
										
											2022-06-03 21:23:23 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      -  [`<promise-iter>.reverse()` ](#promise-iterreverse )
							 
						 
					
						
							
								
									
										
										
										
											2022-06-04 03:10:49 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      -  [`<promise-iter>.concat(..)` ](#promise-iterconcat )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      -  [`<promise-iter>.push(..)` / `<promise-iter>.unshift(..)` ](#promise-iterpush--promise-iterunshift )
							 
						 
					
						
							
								
									
										
										
										
											2022-06-11 11:36:13 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      -  [`<promise-iter>.at(..)` / `<promise-iter>.first()` / `<promise-iter>.last()` ](#promise-iterat--promise-iterfirst--promise-iterlast )
							 
						 
					
						
							
								
									
										
										
										
											2022-07-27 14:50:59 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      -  [`<promise-iter>.join(..)` ](#promise-iterjoin )
							 
						 
					
						
							
								
									
										
										
										
											2022-06-13 22:48:07 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      -  [`<promise-iter>.some(..)` / `<promise-iter>.find(..)` ](#promise-itersome--promise-iterfind )
							 
						 
					
						
							
								
									
										
										
										
											2022-06-11 11:55:44 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      -  [Array proxy methods returning `<promise-iter>` ](#array-proxy-methods-returning-promise-iter )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      -  [Array proxy methods returning a `<promise>` ](#array-proxy-methods-returning-a-promise )
							 
						 
					
						
							
								
									
										
										
										
											2020-11-18 06:09:43 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      -  [`<promise-iter>.then(..)` / `<promise-iter>.catch(..)` / `<promise-iter>.finally(..)` ](#promise-iterthen--promise-itercatch--promise-iterfinally )
							 
						 
					
						
							
								
									
										
										
										
											2022-06-13 22:48:07 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      -  [`promise.IterablePromise.STOP` / `promise.IterablePromise.STOP(..)` ](#promiseiterablepromisestop--promiseiterablepromisestop )
							 
						 
					
						
							
								
									
										
										
										
											2020-11-18 06:09:43 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      -  [Advanced handler ](#advanced-handler )
							 
						 
					
						
							
								
									
										
										
										
											2022-06-13 22:48:07 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      -  [Stopping the iteration ](#stopping-the-iteration )
							 
						 
					
						
							
								
									
										
										
										
											2022-05-30 12:12:00 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    -  [Promise proxies ](#promise-proxies )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      -  [`<promise>.as(..)` ](#promiseas )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      -  [`<promise-proxy>.<method>(..)` ](#promise-proxymethod )
							 
						 
					
						
							
								
									
										
										
										
											2020-11-10 03:25:00 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  -  [Generator extensions and utilities ](#generator-extensions-and-utilities )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    -  [The basics ](#the-basics )
							 
						 
					
						
							
								
									
										
										
										
											2021-03-24 18:57:02 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      -  [`generator.Generator` ](#generatorgenerator )
							 
						 
					
						
							
								
									
										
										
										
											2020-11-10 03:25:00 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      -  [`generator.iter(..)` ](#generatoriter )
							 
						 
					
						
							
								
									
										
										
										
											2021-05-25 17:21:40 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      -  [`generator.STOP` ](#generatorstop )
							 
						 
					
						
							
								
									
										
										
										
											2020-11-10 03:04:04 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    -  [Generator instance iteration ](#generator-instance-iteration )
							 
						 
					
						
							
								
									
										
										
										
											2022-06-23 13:37:46 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      -  [`<generator>.iter(..)` ](#generatoriter-1 )
							 
						 
					
						
							
								
									
										
										
										
											2021-05-25 18:21:30 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      -  [`<generator>.map(..)` / `<generator>.filter(..)` ](#generatormap--generatorfilter )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      -  [`<generator>.reduce(..)` / `<generator>.greduce(..)` ](#generatorreduce--generatorgreduce )
							 
						 
					
						
							
								
									
										
										
										
											2021-03-25 02:59:15 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      -  [`<generator>.slice(..)` ](#generatorslice )
							 
						 
					
						
							
								
									
										
										
										
											2021-05-11 19:10:45 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      -  [`<generator>.at(..)` / `<generator>.gat(..)` ](#generatorat--generatorgat )
							 
						 
					
						
							
								
									
										
										
										
											2021-03-25 02:59:15 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      -  [`<generator>.flat(..)` ](#generatorflat )
							 
						 
					
						
							
								
									
										
										
										
											2021-05-13 15:59:33 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      -  [`<generator>.shift()` / `<generator>.pop()` / `<generator>.gshift()` / `<generator>.gpop()` ](#generatorshift--generatorpop--generatorgshift--generatorgpop )
							 
						 
					
						
							
								
									
										
										
										
											2021-06-26 10:51:49 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      -  [`<generator>.unshift(..)` / `<generator>.push(..)` ](#generatorunshift--generatorpush )
							 
						 
					
						
							
								
									
										
										
										
											2022-07-27 14:50:59 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      -  [`<generator>.join(..)` ](#generatorjoin )
							 
						 
					
						
							
								
									
										
										
										
											2020-11-10 03:04:04 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      -  [`<generator>.then(..)` / `<generator>.catch(..)` / `<generator>.finally(..)` ](#generatorthen--generatorcatch--generatorfinally )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      -  [`<generator>.toArray()` ](#generatortoarray )
							 
						 
					
						
							
								
									
										
										
										
											2021-06-01 01:12:51 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    -  [Treating iterators the same as generators ](#treating-iterators-the-same-as-generators )
							 
						 
					
						
							
								
									
										
										
										
											2020-11-18 06:59:56 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    -  [Generator constructor iteration ](#generator-constructor-iteration )
							 
						 
					
						
							
								
									
										
										
										
											2021-06-23 09:05:19 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      -  [`<Generator>.iter(..)` ](#generatoriter-2 )
							 
						 
					
						
							
								
									
										
										
										
											2021-05-11 19:10:45 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      -  [`<Generator>.at(..)` / `<Generator>.gat(..)` ](#generatorat--generatorgat-1 )
							 
						 
					
						
							
								
									
										
										
										
											2021-05-13 15:59:33 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      -  [`<Generator>.shift()` / `<Generator>.pop()` / `<Generator>.gshift()` / `<Generator>.gpop()` ](#generatorshift--generatorpop--generatorgshift--generatorgpop-1 )
							 
						 
					
						
							
								
									
										
										
										
											2021-06-26 10:51:49 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      -  [`<generator>.unshift(..)` / `<generator>.push(..)` ](#generatorunshift--generatorpush-1 )
							 
						 
					
						
							
								
									
										
										
										
											2021-03-25 02:59:15 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      -  [`<Generator>.slice(..)` ](#generatorslice-1 )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      -  [`<Generator>.map(..)` / `<Generator>.filter(..)` / `<Generator>.reduce(..)` / `<Generator>.flat()` ](#generatormap--generatorfilter--generatorreduce--generatorflat )
							 
						 
					
						
							
								
									
										
										
										
											2021-03-24 18:57:02 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      -  [`<Generator>.toArray()` ](#generatortoarray-1 )
							 
						 
					
						
							
								
									
										
										
										
											2022-07-27 14:50:59 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      -  [`<Generator>.join(..)` ](#generatorjoin-1 )
							 
						 
					
						
							
								
									
										
										
										
											2021-03-24 18:57:02 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      -  [`<Generator>.then(..)` / `<Generator>.catch(..)` / `<Generator>.finally(..)` ](#generatorthen--generatorcatch--generatorfinally-1 )
							 
						 
					
						
							
								
									
										
										
										
											2021-05-25 17:21:40 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    -  [Generator combinators ](#generator-combinators )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      -  [`<Generator>.chain(..)` / `<generator>.chain(..)` ](#generatorchain--generatorchain )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      -  [`<Generator>.concat(..)` / `<generator>.concat(..)` ](#generatorconcat--generatorconcat )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    -  [Generator library ](#generator-library )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      -  [`generator.range(..)` ](#generatorrange )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      -  [`generator.repeat(..)` ](#generatorrepeat )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      -  [`generator.produce(..)` ](#generatorproduce )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    -  [Generator helpers ](#generator-helpers )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      -  [`generator.stoppable(..)` ](#generatorstoppable )
							 
						 
					
						
							
								
									
										
										
										
											2022-06-17 12:01:04 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  -  [Async generator extensions ](#async-generator-extensions )
							 
						 
					
						
							
								
									
										
										
										
											2022-06-22 10:26:04 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      -  [`generator.AsyncGenerator` ](#generatorasyncgenerator )
							 
						 
					
						
							
								
									
										
										
										
											2022-06-21 13:49:50 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      -  [`<async-generator>.then(..)` / `<async-generator>.catch(..)` / `<async-generator>.finally(..)` ](#async-generatorthen--async-generatorcatch--async-generatorfinally )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      -  [`<async-generator>.iter(..)` ](#async-generatoriter )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      -  [`<async-generator>.map(..)` / `<async-generator>.filter(..)` / `<async-generator>.reduce(..)` ](#async-generatormap--async-generatorfilter--async-generatorreduce )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      -  [`<async-generator>.chain(..)` ](#async-generatorchain )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      -  [`<async-generator>.flat(..)` ](#async-generatorflat )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      -  [`<async-generator>.concat(..)` ](#async-generatorconcat )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      -  [`<async-generator>.push(..)` / `<async-generator>.unshift(..)` ](#async-generatorpush--async-generatorunshift )
							 
						 
					
						
							
								
									
										
										
										
											2020-10-07 03:53:10 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  -  [Containers ](#containers )
							 
						 
					
						
							
								
									
										
										
										
											2020-10-07 07:33:58 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    -  [`containers.UniqueKeyMap()` (`Map`) ](#containersuniquekeymap-map )
							 
						 
					
						
							
								
									
										
										
										
											2020-10-07 14:48:47 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      -  [`<unique-key-map>.set(..)` ](#unique-key-mapset )
							 
						 
					
						
							
								
									
										
										
										
											2020-10-07 03:53:10 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      -  [`<unique-key-map>.reset(..)` ](#unique-key-mapreset )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      -  [`<unique-key-map>.rename(..)` ](#unique-key-maprename )
							 
						 
					
						
							
								
									
										
										
										
											2020-10-07 15:09:36 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      -  [`<unique-key-map>.orderedRename(..)` ](#unique-key-maporderedrename )
							 
						 
					
						
							
								
									
										
										
										
											2020-10-07 14:48:47 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      -  [`<unique-key-map>.unorderedRename(..)` ](#unique-key-mapunorderedrename )
							 
						 
					
						
							
								
									
										
										
										
											2020-10-07 03:53:10 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      -  [`<unique-key-map>.keysOf(..)` ](#unique-key-mapkeysof )
							 
						 
					
						
							
								
									
										
										
										
											2020-10-07 14:48:47 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      -  [`<unique-key-map>.originalKey(..)` ](#unique-key-maporiginalkey )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      -  [`<unique-key-map>.uniqueKey(..)` ](#unique-key-mapuniquekey )
							 
						 
					
						
							
								
									
										
										
										
											2020-10-07 07:33:58 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      -  [`<unique-key-map>.__key_pattern__` ](#unique-key-map__key_pattern__ )
							 
						 
					
						
							
								
									
										
										
										
											2020-10-07 15:09:36 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      -  [`<unique-key-map>.__unordered_rename__` ](#unique-key-map__unordered_rename__ )
							 
						 
					
						
							
								
									
										
										
										
											2020-11-15 05:13:35 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  -  [Event ](#event )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    -  [`event.Eventfull(..)` ](#eventeventfull )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    -  [`event.Event(..)` ](#eventevent )
							 
						 
					
						
							
								
									
										
										
										
											2020-11-16 02:38:19 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    -  [`event.TRIGGER` ](#eventtrigger )
							 
						 
					
						
							
								
									
										
										
										
											2020-11-15 05:13:35 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    -  [`event.EventHandlerMixin` ](#eventeventhandlermixin )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      -  [`<obj>.on(..)` ](#objon )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      -  [`<obj>.one(..)` ](#objone )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      -  [`<obj>.off(..)` ](#objoff )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      -  [`<obj>.trigger(..)` ](#objtrigger )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    -  [`event.EventDocMixin` ](#eventeventdocmixin )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      -  [`<obj>.eventfull` ](#objeventfull )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      -  [`<obj>.events` ](#objevents )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    -  [`event.EventMixin` ](#eventeventmixin )
							 
						 
					
						
							
								
									
										
										
										
											2020-11-07 03:19:52 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  -  [Runner ](#runner )
							 
						 
					
						
							
								
									
										
										
										
											2020-11-28 03:47:31 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    -  [Micro task queue ](#micro-task-queue )
							 
						 
					
						
							
								
									
										
										
										
											2021-05-26 11:57:21 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      -  [`runner.STOP` ](#runnerstop )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      -  [`runner.SKIP` ](#runnerskip )
							 
						 
					
						
							
								
									
										
										
										
											2020-12-08 01:53:40 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      -  [`Queue(..)` / `Queue.runTasks(..)` ](#queue--queueruntasks )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      -  [`Queue.handle(..)` ](#queuehandle )
							 
						 
					
						
							
								
									
										
										
										
											2020-11-07 03:19:52 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      -  [`<queue>.state` ](#queuestate )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      -  [`<queue>.start(..)` ](#queuestart )
							 
						 
					
						
							
								
									
										
										
										
											2020-12-08 01:53:40 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      -  [`<queue>.stop(..)` ](#queuestop )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      -  [`<queue>.runTask(..)` ](#queueruntask )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      -  [`<queue>.tasksAdded(..)` (event) ](#queuetasksadded-event )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      -  [`<queue>.taskStarting(..)` (event) ](#queuetaskstarting-event )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      -  [`<queue>.taskFailed(..)` (event) ](#queuetaskfailed-event )
							 
						 
					
						
							
								
									
										
										
										
											2020-11-07 03:19:52 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      -  [`<queue>.taskCompleted(..)` (event) ](#queuetaskcompleted-event )
							 
						 
					
						
							
								
									
										
										
										
											2020-12-08 01:53:40 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      -  [`<queue>.queueEmpty(..)` (event) ](#queuequeueempty-event )
							 
						 
					
						
							
								
									
										
										
										
											2020-12-17 18:55:28 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      -  [`<queue>.prioritize(..)` ](#queueprioritize )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      -  [`<queue>.delay(..)` ](#queuedelay )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      -  [`<queue>.add(..)` ](#queueadd )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      -  [`<queue>.clear(..)` ](#queueclear )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      -  [`FinalizableQueue(..)` / `FinalizableQueue.runTasks(..)` (Queue) ](#finalizablequeue--finalizablequeueruntasks-queue )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      -  [`<finalizable-queue>.done(..)` (event/method) ](#finalizable-queuedone-eventmethod )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      -  [`<finalizable-queue>.abort(..)` (event/method) ](#finalizable-queueabort-eventmethod )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      -  [`<finalizable-queue>.promise(..)` ](#finalizable-queuepromise )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      -  [`<finalizable-queue>.then(..)` ](#finalizable-queuethen )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      -  [`<finalizable-queue>.catch(..)` ](#finalizable-queuecatch )
							 
						 
					
						
							
								
									
										
										
										
											2020-11-28 03:47:31 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    -  [Large task management ](#large-task-management )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      -  [`runner.TaskManager(..)` ](#runnertaskmanager )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      -  [`<task-manager>.Task(..)` ](#task-managertask )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      -  [`<task-manager>.sync_start` ](#task-managersync_start )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      -  [`<task-manager>.record_times` ](#task-managerrecord_times )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      -  [`<task-manager>.titled(..)` ](#task-managertitled )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      -  [`<task-manager>.send(..)` ](#task-managersend )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      -  [`<task-manager>.stop(..)` ](#task-managerstop )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      -  [`<task-manager>.done(..)` (event) ](#task-managerdone-event )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      -  [`<task-manager>.error(..)` (event) ](#task-managererror-event )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      -  [`<task-manager>.tasksDone(..)` (event) ](#task-managertasksdone-event )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      -  [`runner.TaskTicket(..)` ](#runnertaskticket )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      -  [`runner.TaskMixin(..)` ](#runnertaskmixin )
							 
						 
					
						
							
								
									
										
										
										
											2020-10-07 07:33:58 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  -  [License ](#license )
							 
						 
					
						
							
								
									
										
										
										
											2020-10-07 03:53:10 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-10-07 07:33:58 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								## Installation
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```shell
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								$ npm install -s 'ig-types'
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								## Basic usage
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								To extend everything:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```javascript
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								require('ig-types')
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-10-09 23:20:00 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								To have access to additional library types and utilities:
							 
						 
					
						
							
								
									
										
										
										
											2020-10-07 07:33:58 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								```javascript
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								var types = require('ig-types')
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								`types.js`  is organized so as to be able to import/extend only specific  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								sub-modules mostly independently so...
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-10-09 23:20:00 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								In case there is a need to only extend a specific constructor just import 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								the module dealing with that constructor (`Array`  in this case):
							 
						 
					
						
							
								
									
										
										
										
											2020-10-07 07:33:58 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								```javascript
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// require `ig-types/<constructor-name>` ...
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								require('ig-types/Array')
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
									
										
										
										
											2021-03-24 02:10:55 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Note that type patching modules are _mostly_  independent.
							 
						 
					
						
							
								
									
										
										
										
											2020-10-07 07:33:58 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								And to import specific library modules only:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```javascript
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								var containers = require('ig-types/containers')
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-18 06:09:43 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								## `Object`
  
						 
					
						
							
								
									
										
										
										
											2020-10-07 03:53:10 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-18 06:09:43 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								```javascript
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								require('ig-types/Object')
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
									
										
										
										
											2020-10-07 03:53:10 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-03-24 02:10:55 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Note that this module imports from 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								[`object.js` ](https://github.com/flynx/object.js ) and 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								[`object-run.js` ](https://github.com/flynx/object-run.js ),
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								see those modules for more details.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-18 06:09:43 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								### `Object.deepKeys(..)`
  
						 
					
						
							
								
									
										
										
										
											2020-10-07 03:53:10 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-03-24 02:10:55 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Get list of keys from all objects in the prototype chain.
							 
						 
					
						
							
								
									
										
										
										
											2020-12-08 01:53:40 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								```bnf
							 
						 
					
						
							
								
									
										
										
										
											2020-10-09 23:20:00 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Object.deepKeys(< obj > )
							 
						 
					
						
							
								
									
										
										
										
											2020-12-08 01:53:40 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    -> < keys > 
							 
						 
					
						
							
								
									
										
										
										
											2020-10-09 23:20:00 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
									
										
										
										
											2020-10-07 03:53:10 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-10-09 23:20:00 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								This is different from `Object.keys(..)`  which only gets _own_  keys from the 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								current object.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Example:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```javascript
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								var a = { x: 123 }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								var b = Object.create(a)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								b.y = 321
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// get own keys of b...
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Object.keys(b) // -> ['y']
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// get all keys accessible from b...
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Object.deepKeys(b) // -> ['x', 'y']
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-03-24 02:10:55 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								For more details see:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								https://github.com/flynx/object.js#deepkeys 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-18 06:09:43 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								### `Object.copy(..)` (EXPERIMENTAL)
  
						 
					
						
							
								
									
										
										
										
											2020-10-10 06:27:51 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-03-24 02:10:55 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Create a copy of `<obj>` 
							 
						 
					
						
							
								
									
										
										
										
											2020-12-08 01:53:40 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								```bnf
							 
						 
					
						
							
								
									
										
										
										
											2020-10-10 06:27:51 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Object.copy(< obj > )
							 
						 
					
						
							
								
									
										
										
										
											2020-12-08 01:53:40 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    -> < obj-copy > 
							 
						 
					
						
							
								
									
										
										
										
											2020-10-10 06:27:51 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-03-24 02:10:55 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Object.copy(< obj > , < constructor > )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    -> < obj-copy > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
									
										
										
										
											2020-10-10 06:27:51 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								This will:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								-  create a blank `<obj-copy>`  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								-  link `<obj-copy>`  to the same prototype chain 
						 
					
						
							
								
									
										
										
										
											2021-03-24 02:10:55 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								-  assign all _own_  keys from `<obj>`  to `<obj-copy>`  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								This is similar to `Object.clone(..)`  but instead of creating a new descendant of 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								the input object with no data this will instead create a new sibling with a copy
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								of the instance data.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								`<constructor>`  if given is called to create the instance to be populated,  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								otherwise `Object.create(<obj>)`  is used.
							 
						 
					
						
							
								
									
										
										
										
											2020-10-10 06:27:51 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-03-24 02:10:55 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Note that `.assign(..)`  is used to copy data, thus properties will be copied as values, to copy instance properties use `object.js` 's 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								[`.mixinFlat(..)` ](https://github.com/flynx/object.js#mixinflat ).
							 
						 
					
						
							
								
									
										
										
										
											2020-10-10 06:27:51 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-03-24 02:10:55 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Note that this will make no attempt to clone object type, a `<constructor>`  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								should be passed manually if any instance type other that `Object`  is required.
							 
						 
					
						
							
								
									
										
										
										
											2020-10-10 06:27:51 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-10-07 03:53:10 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-18 06:09:43 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								### `Object.flatCopy(..)`
  
						 
					
						
							
								
									
										
										
										
											2020-10-07 03:53:10 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-03-24 02:10:55 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Copy all attributes from the prototype chain of `<obj>`  into `<new-obj>` .
							 
						 
					
						
							
								
									
										
										
										
											2020-12-08 01:53:40 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								```bnf
							 
						 
					
						
							
								
									
										
										
										
											2020-10-10 06:27:51 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Object.flatCopy(< obj > )
							 
						 
					
						
							
								
									
										
										
										
											2020-12-08 01:53:40 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    -> < new-obj > 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-24 02:10:55 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Object.flatCopy(< obj > , < constructor > )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    -> < new-obj > 
							 
						 
					
						
							
								
									
										
										
										
											2020-10-10 06:27:51 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-03-24 02:10:55 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								This is different to [`.copy(..)` ](#objectcopy-experimental ) in that if 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								no `<constructor>`  is given `<new-obj>`  will _not_  be linked into the 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								prototype chain of `<obj>` , if this behavior is desired use `o => Object.create(o)` 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								as the `<constructor>` .
							 
						 
					
						
							
								
									
										
										
										
											2020-10-10 06:27:51 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-18 06:09:43 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								### `Object.match(..)`
  
						 
					
						
							
								
									
										
										
										
											2020-10-09 23:20:00 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-03-24 02:10:55 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Attribute/value match two objects (non-recursive).
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```bnf
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Object.match(< object > , < other > )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    -> < bool > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Objects `A`  and `B`  match iff:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								-  `A`  and `B`  are _identical_ , i.e. `A === B`  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								or
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								-  `typeof A == typeof B`  _and_ , 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								-  `A`  and `B`  have the same number of attributes _and_ , 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								-  attribute names match _and_ , 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								-  attribute values are _identical_ . 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								And for a less strict match:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```bnf
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Object.match(< object > , < other > , true)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    -> < bool > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Like the default case but uses _equality_  instead of _identity_  to match values.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								For more details see:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								https://github.com/flynx/object.js#match 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								<!--  
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								XXX should this test based on equality or on identity by default??? 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    ...see: Array.cmp(..)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								-->
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-18 06:09:43 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								### `Object.matchPartial(..)`
  
						 
					
						
							
								
									
										
										
										
											2020-10-09 23:20:00 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-03-24 02:10:55 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								```bnf
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Object.matchPartial(< object > , < other > )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    -> < bool > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Object.matchPartial(< object > , < other > , true)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    -> < bool > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Like `.match(..)`  but will check for a _partial_  match, i.e. when `<other>`  is a non-strict subset of `<object>` .
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								For more details see:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								https://github.com/flynx/object.js#matchpartial 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								<!--  
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								XXX should this test based on equality or on identity by default??? 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    ...see: Array.cmp(..)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								-->
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-18 06:09:43 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								### `<object>.run(..)`
  
						 
					
						
							
								
									
										
										
										
											2020-10-07 03:53:10 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-12-08 01:53:40 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								```bnf
							 
						 
					
						
							
								
									
										
										
										
											2020-10-07 07:33:58 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								< object > .run(< func > ) 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    -> < object > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    -> < other > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Run a function in the context of `<object>`  returning either `<object>`  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								itself (if returning `undefined` ) or the result.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Note that this is accessible from all JavaScript non-primitive objects, 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								i.e. everything that inherits from `Object` .
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Example:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```javascript
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								var L = [1, 2, 3]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    .map(function(e){
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return e * 2 })
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    // see if the first element is 1 and prepend 1 if it is not...
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    .run(function(){
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if(this[0] != 1){
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            this.unshift(1) } })
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								console.log(L) // -> [1, 2, 6, 8]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								`.run(..)`  is also available standalone via: 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```shell
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								$ npm install -s object-run
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-03-24 02:10:55 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								For more details see:  
							 
						 
					
						
							
								
									
										
										
										
											2020-10-07 07:33:58 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								https://github.com/flynx/object-run.js
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-10-07 03:53:10 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-18 06:09:43 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								### `Object.sort(..)`
  
						 
					
						
							
								
									
										
										
										
											2020-10-07 16:46:59 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-03-24 02:10:55 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Sort `<obj>`  attributes (similar to `Array` 's `.sort(..)` )
							 
						 
					
						
							
								
									
										
										
										
											2020-12-08 01:53:40 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								```bnf
							 
						 
					
						
							
								
									
										
										
										
											2020-10-10 06:27:51 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Object.sort(< obj > )
							 
						 
					
						
							
								
									
										
										
										
											2020-12-08 01:53:40 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    -> < obj > 
							 
						 
					
						
							
								
									
										
										
										
											2020-10-10 06:27:51 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Sort `<obj>`  attributes via `<cmp>`  function.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Object.sort(< obj > , < cmp > )
							 
						 
					
						
							
								
									
										
										
										
											2020-12-08 01:53:40 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    -> < obj > 
							 
						 
					
						
							
								
									
										
										
										
											2020-10-10 06:27:51 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Sort `<obj>`  attributes to the same order of `<order-list>` .
							 
						 
					
						
							
								
									
										
										
										
											2020-12-08 01:53:40 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								```bnf
							 
						 
					
						
							
								
									
										
										
										
											2020-10-10 06:27:51 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Object.sort(< obj > , < order-list > )
							 
						 
					
						
							
								
									
										
										
										
											2020-12-08 01:53:40 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    -> < obj > 
							 
						 
					
						
							
								
									
										
										
										
											2020-10-10 06:27:51 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Note that this rewrites all the keys of `<obj>`  thus for very large
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								sets of keys/attributes this may be quite expensive.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Note that some keys of `Object`  may misbehave in JavaScript, currently keys
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								that are string values of numbers are sorted automatically by _number value_ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								and are not affected by `.sort(..)` , this affects both _Chrome_  and _Firefox_ .
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Example:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```javascript
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								var o = {x: 0, a: 1, '100':2, '0':3, ' 27 ':4, b:5}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// notice that the order is already different to the order of attributes above...
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Object.keys(o) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								//    -> ['0', '100', 'x', 'a', ' 27 ', 'b']
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// '0' and '100' are not affected by .sort(..) while ' 27 ' is...
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Object.keys(Object.sort(o, ['x', 'a', '100'])) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								//    -> [ '0', '100', 'x', 'a', ' 27 ', 'b' ]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-04-03 02:11:02 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								This is similar to [`<map>.sort(..)` ](#mapsort ) and [`<ser>.sort(..)` ](#setsort ).
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-10-07 16:46:59 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-07 11:39:08 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								## `Function`
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```javascript
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								var func = require('ig-types/Function')
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								### `func.AsyncFunction`
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								The async function constructor.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								This enables us to test if an object is an instance of an async function. 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```javascript
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								var a = async function(){
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    // ...
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								a instanceof func.AsyncFunction // -> true
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								This is hidden by JavaScript by default.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-18 06:09:43 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								## `Array`
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```javascript
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								require('ig-types/Array')
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								or
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```javascript
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								var array = require('ig-types/Array')
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
									
										
										
										
											2020-10-07 03:53:10 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-18 06:09:43 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								### `<array>.first(..)` / `<array>.last(..)`
  
						 
					
						
							
								
									
										
										
										
											2020-10-07 03:53:10 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-10-07 16:46:59 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Get the first/last items of `<array>` .
							 
						 
					
						
							
								
									
										
										
										
											2020-12-08 01:53:40 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								```bnf
							 
						 
					
						
							
								
									
										
										
										
											2020-10-07 16:46:59 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								< array > .first() 
						 
					
						
							
								
									
										
										
										
											2020-12-08 01:53:40 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    -> < item > 
							 
						 
					
						
							
								
									
										
										
										
											2020-10-07 16:46:59 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< array > .last() 
						 
					
						
							
								
									
										
										
										
											2020-12-08 01:53:40 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    -> < item > 
							 
						 
					
						
							
								
									
										
										
										
											2020-10-07 16:46:59 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Set the first/last items of `<array>` .
							 
						 
					
						
							
								
									
										
										
										
											2020-12-08 01:53:40 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								```bnf
							 
						 
					
						
							
								
									
										
										
										
											2020-10-07 16:46:59 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								< array > .first(< item > ) 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  -> < array > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< array > .last(< item > ) 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  -> < array > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Note that these do not affect `<array>`  length unless setting items on 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								an empty `<array>` .
							 
						 
					
						
							
								
									
										
										
										
											2020-10-07 03:53:10 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-18 06:09:43 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								### `<array>.rol(..)`
  
						 
					
						
							
								
									
										
										
										
											2020-11-16 18:55:31 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Roll `<array>`  in-place left.
							 
						 
					
						
							
								
									
										
										
										
											2020-12-08 01:53:40 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								```bnf
							 
						 
					
						
							
								
									
										
										
										
											2020-11-16 18:55:31 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								< array > .rol() 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< array > .rol(1) 
						 
					
						
							
								
									
										
										
										
											2020-12-08 01:53:40 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    -> < array > 
							 
						 
					
						
							
								
									
										
										
										
											2020-11-16 18:55:31 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< array > .rol(n) 
						 
					
						
							
								
									
										
										
										
											2020-12-08 01:53:40 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    -> < array > 
							 
						 
					
						
							
								
									
										
										
										
											2020-11-16 18:55:31 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-03-24 02:10:55 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								To roll _right_  pass a negative `n`  to `.rol(..)` .
							 
						 
					
						
							
								
									
										
										
										
											2020-11-16 18:55:31 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-18 06:09:43 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								### `<array>.compact()`
  
						 
					
						
							
								
									
										
										
										
											2020-10-07 03:53:10 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-12-08 01:53:40 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								```bnf
							 
						 
					
						
							
								
									
										
										
										
											2020-10-07 16:46:59 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								< array > .compact() 
						 
					
						
							
								
									
										
										
										
											2020-12-08 01:53:40 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    -> < compact-array > 
							 
						 
					
						
							
								
									
										
										
										
											2020-10-07 16:46:59 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-10-07 03:53:10 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Generate a compact `<array>`  from a sparse `<array>` , i.e. removing all
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								the empty slots.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-18 06:09:43 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								### `<array>.len`
  
						 
					
						
							
								
									
										
										
										
											2020-10-07 03:53:10 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Number of non-empty slots/elements in `<array>` .
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-10-07 16:46:59 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								This is similar to:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```javascript
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								var L = [,,, 1,, 2, 3,,]
							 
						 
					
						
							
								
									
										
										
										
											2020-10-07 03:53:10 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-10-07 16:46:59 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								// this is the same as L.len...
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								L.compact().length 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
									
										
										
										
											2020-10-07 03:53:10 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-10-07 16:46:59 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Note that this is different from `.length`  in that writing to `.len`  has
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								no effect.
							 
						 
					
						
							
								
									
										
										
										
											2020-10-07 03:53:10 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-03-24 02:10:55 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-12-08 01:53:40 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								### `<array>.unique()` / `<array>.tailUnique()`
  
						 
					
						
							
								
									
										
										
										
											2020-10-07 03:53:10 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Generate an array with all duplicate elements removed.
							 
						 
					
						
							
								
									
										
										
										
											2020-12-08 01:53:40 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								```bnf
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< array > .unique() 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    -> < array > 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-24 02:10:55 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< array > .tailUnique() 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    -> < array > 
							 
						 
					
						
							
								
									
										
										
										
											2020-12-08 01:53:40 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
									
										
										
										
											2020-11-16 18:55:31 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-03-24 02:10:55 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								The difference between the two versions is in that `.unique(..)`  keeps the 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								first occurrence of a value while `.tailUnique(..)`  keeps the last.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-12-08 01:53:40 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								### `<array>.trim()` / `<array>.trimStart()` / `<array>.trimEnd()`
  
						 
					
						
							
								
									
										
										
										
											2020-10-07 03:53:10 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-12-08 01:53:40 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Copy array removing empty slots from array start, end or both.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```bnf
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< array > .trim() 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    -> < array > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< array > .trimStart() 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    -> < array > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< array > .trimEnd() 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    -> < array > 
							 
						 
					
						
							
								
									
										
										
										
											2020-10-07 16:46:59 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
									
										
										
										
											2020-12-08 01:53:40 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-03-24 02:10:55 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								This is similar to `String` 's equivalent methods but removing _empty_  slots 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								instead of spaces.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-12-08 01:53:40 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								### `<array>.cmp(..)`
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Compare two arrays.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```bnf
							 
						 
					
						
							
								
									
										
										
										
											2020-10-07 16:46:59 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								< array > .cmp(< other > ) 
						 
					
						
							
								
									
										
										
										
											2020-12-08 01:53:40 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    -> < bool > 
							 
						 
					
						
							
								
									
										
										
										
											2020-10-07 16:46:59 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								This will return `true`  if:
							 
						 
					
						
							
								
									
										
										
										
											2021-03-24 02:10:55 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								-  `<array> === <other>`   
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								or
							 
						 
					
						
							
								
									
										
										
										
											2020-10-07 16:46:59 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								-  lengths are the same and, 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								-  values on the same positions are equal. 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-03-24 02:10:55 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								<!--  
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								XXX should this test based on equality or on identity by default??? 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    ...see: Object.match(..)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								-->
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-10-07 16:46:59 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-18 06:09:43 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								### `<array>.setCmp(..)`
  
						 
					
						
							
								
									
										
										
										
											2020-10-07 03:53:10 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-12-08 01:53:40 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Compare to arrays ignoring element order and count.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```bnf
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< array > .setCmp(< other > ) 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    -> < bool > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-03-24 02:10:55 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-18 06:09:43 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								### `<array>.sortAs(..)`
  
						 
					
						
							
								
									
										
										
										
											2020-10-07 03:53:10 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-12-08 01:53:40 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Sort array as a different array.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```bnf
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< array > .sortAs(< other > ) 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    -> < array > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Elements not present in `<other>`  retain their relative order and are
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								placed after the sorted elements.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Example:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```javascript
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								var L = [1, 2, 3, 4, 5, 6]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								var O = [5, 3, 1, 0]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								L.sortAs(O) // -> [5, 3, 1, 2, 4, 6]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-18 06:09:43 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								### `<array>.inplaceSortAs(..)`
  
						 
					
						
							
								
									
										
										
										
											2020-10-07 03:53:10 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-12-08 01:53:40 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Sort array as a different array keeping positions of unsorted elements.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```bnf
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< array > .inplaceSortAs(< other > ) 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    -> < array > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Example:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```javascript
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								var L = [1, 2, 3, 4, 5, 6]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								var O = [5, 3, 1, 0]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								L.inplaceSortAs(O) // -> [5, 2, 3, 4, 1, 6]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-18 06:09:43 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								### `<array>.toKeys(..)`
  
						 
					
						
							
								
									
										
										
										
											2020-10-10 17:27:00 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-12-08 01:53:40 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Create an object with array values as keys and index as value.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```bnf
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< array > .toKeys() 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    -> < object > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Normalize resulting `<object>`  keys:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```bnf
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< array > .toKeys(< normalize > ) 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    -> < object > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< normalize > (< elem > , < index > ) 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    -> < key > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								If `<array>`  contains the same value multiple times it will be written 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								to `<object>`  only once with the last occurrences' index.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Since `object`  keys can only be `string` s array items that are not
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								strings will be converted to strings. If this is not desired use `.toMap(..)` 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								instead.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-18 06:09:43 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								### `<array>.toMap(..)`
  
						 
					
						
							
								
									
										
										
										
											2020-10-10 17:27:00 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-12-08 01:53:40 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Create a map with array values as keys and index as value.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```bnf
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< array > .toMap() 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    -> < map > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Normalize resulting `<map>`  keys:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```bnf
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< array > .toMap(< normalize > ) 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    -> < map > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< normalize > (< elem > , < index > ) 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    -> < key > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Note that if `<array>`  contains the same value multiple times it will be used 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								as key only once and retain the last occurrences' index.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-18 06:09:43 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								### `Array.zip(..)` / `<array>.zip(..)`
  
						 
					
						
							
								
									
										
										
										
											2020-10-15 03:12:42 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-12-08 01:53:40 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								_Zip_ input array items.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```bnf
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Array.zip(< array > , < array > , ..)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    -> < array > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< array > .zip(< array > , < array > , ..) 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    -> < array > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Example:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```javascript
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								var A = [1, 2, 3]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								var B = ['a', 'b', 'c', 'd']
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Array.zip(A, B) // -> [[1, 'a'], [2, 'b'], [3, 'c'], [, 'd']]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Array _sparseness_  is retained -- if one of the arrays has an empty slot, or is 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								not long enough, the corresponding spot in the result will be empty.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Resulting array length is strictly equal to the longest input array length.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-18 06:59:56 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								### `Array.iter(..)` / `<array>.iter()`
  
						 
					
						
							
								
									
										
										
										
											2020-11-10 03:04:04 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Return an iterator/generator from the current array.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-10 03:25:00 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								This is mostly useful in combination with the [Generator extensions and utilities ](#generator-extensions-and-utilities )
							 
						 
					
						
							
								
									
										
										
										
											2020-11-10 03:04:04 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-10-10 17:27:00 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-07 03:19:52 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								### Abortable `Array` iteration
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-16 18:55:31 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								A an alternative to `Array` 's `.map(..)`  / `.filter(..)`  / .. methods with ability to
							 
						 
					
						
							
								
									
										
										
										
											2020-11-23 22:27:30 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								stop the iteration process by `throw` ing `STOP`  or `STOP(<value>)` .
							 
						 
					
						
							
								
									
										
										
										
											2020-11-07 03:19:52 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```javascript
							 
						 
					
						
							
								
									
										
										
										
											2020-11-23 22:27:30 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								var {STOP} = require('ig-types/Array')
							 
						 
					
						
							
								
									
										
										
										
											2020-11-07 03:19:52 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								This can be used in two ways:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								1) `throw`  as-is to simply stop...
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    ```javascript
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    ;[1,2,3,4,5]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        .smap(function(e){ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            // simply abort here and now...
							 
						 
					
						
							
								
									
										
										
										
											2020-11-23 22:27:30 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            throw STOP })
							 
						 
					
						
							
								
									
										
										
										
											2020-11-07 03:19:52 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    ```
							 
						 
					
						
							
								
									
										
										
										
											2020-11-23 22:27:30 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    Since we aborted the iteration without passing any arguments to `STOP` ,
							 
						 
					
						
							
								
									
										
										
										
											2020-11-07 03:19:52 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    `.smap(..)`  will return `undefined` .
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								2) `throw`  an instance and return the argument...
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    ```javascript
							 
						 
					
						
							
								
									
										
										
										
											2020-11-23 22:27:30 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    // this will print "4" -- the value passed to STOP...
							 
						 
					
						
							
								
									
										
										
										
											2020-11-07 03:19:52 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    console.log([1,2,3,4,5]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        .smap(function(e){ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            if(e > 3){
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								              // NOTE: new is optional here...
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								              //    ...StopIteratiom is an object.js constructor.
							 
						 
					
						
							
								
									
										
										
										
											2020-11-23 22:27:30 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								              throw new STOP(e) } }))
							 
						 
					
						
							
								
									
										
										
										
											2020-11-07 03:19:52 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    ```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-23 22:27:30 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Note that no partial result is returned unless passed through `STOP(..)` .
							 
						 
					
						
							
								
									
										
										
										
											2020-11-16 18:55:31 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-23 22:27:30 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								#### `array.STOP` / `array.STOP(..)`
  
						 
					
						
							
								
									
										
										
										
											2020-11-16 18:55:31 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-23 22:27:30 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								An _object/constructor_  that if raised (as an exception) while iterating via 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								a supporting iterator method will abort further execution and correctly exit.
							 
						 
					
						
							
								
									
										
										
										
											2020-11-07 03:19:52 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								#### `<array>.smap(..)` / `<array>.sfilter(..)` / `<array>.sreduce(..)` / `<array>.sforEach(..)`
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Like `Array` 's `.map(..)` , `.filter(..)` , `.reduce(..)`  and `.forEach(..)`  but 
							 
						 
					
						
							
								
									
										
										
										
											2020-11-23 22:27:30 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								with added support for aborting iteration by throwing `STOP`  or `STOP(<value>)` .
							 
						 
					
						
							
								
									
										
										
										
											2020-11-07 03:19:52 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-10-10 17:27:00 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								### Large `Array` iteration (chunked)
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Iterating over very large `Array`  instances in JavaScript can block execution,
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								to avoid this `types.js`  implements `.map(..)` /`.filter(..)` /`.reduce(..)` 
							 
						 
					
						
							
								
									
										
										
										
											2020-10-11 03:09:48 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								equivalent methods that iterate the array in chunks and do it asynchronously 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								giving the runtime a chance to run in between.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								In the simplest cases these are almost a drop-in replacements for the equivalent
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								methods but return a promise.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```javascript
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								var a = [1,2,3,4,5]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    .map(function(e){ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return e*2 })
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								var b
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								;[1,2,3,4,5]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    .mapChunks(function(e){ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return e*2 })
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    .then(function(res){
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        b = res })
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// or with await...
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								var c = await [1,2,3,4,5]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    .mapChunks(function(e){ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return e*2 })
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								These support setting the chunk size (default: `50` ) as the first argument:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```javascript
							 
						 
					
						
							
								
									
										
										
										
											2020-11-07 03:19:52 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								var c = await [1,2,3,4,5]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    .mapChunks(2, function(e){ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return e*2 })
							 
						 
					
						
							
								
									
										
										
										
											2020-10-11 03:09:48 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-23 22:27:30 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								#### `array.STOP` / `array.STOP(..)`
  
						 
					
						
							
								
									
										
										
										
											2020-11-06 16:57:51 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-07 03:19:52 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Like for [`<array>.smap(..)` and friends ](#abortable-array-iteration ) iteration 
							 
						 
					
						
							
								
									
										
										
										
											2020-11-23 22:27:30 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								can be stopped by throwing a `array.STOP`  / `array.STOP(<value>)`  and as before 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								there are two ways to go:
							 
						 
					
						
							
								
									
										
										
										
											2020-11-06 16:57:51 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								1) `throw`  as-is to simply stop
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    ```javascript
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    ;[1,2,3,4,5]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        .mapChunks(function(e){ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            // simply abort here and now...
							 
						 
					
						
							
								
									
										
										
										
											2020-11-23 22:27:30 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            throw STOP })
							 
						 
					
						
							
								
									
										
										
										
											2020-11-06 16:57:51 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        .catch(function(){
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            console.log('done.') })
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    ```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								2) `Throw`  an instance and pass a value to `.catch(..)` 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								   ```javascript
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    ;[1,2,3,4,5]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        .mapChunks(function(e){ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            if(e > 3){
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								              // NOTE: new is optional here...
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								              //    ...StopIteratiom is an object.js constructor.
							 
						 
					
						
							
								
									
										
										
										
											2020-11-23 22:27:30 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								              throw new STOP(e) } })
							 
						 
					
						
							
								
									
										
										
										
											2020-11-06 16:57:51 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        .catch(function(e){
							 
						 
					
						
							
								
									
										
										
										
											2020-11-07 03:19:52 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            console.log('first value greater than 3:', e) })
							 
						 
					
						
							
								
									
										
										
										
											2020-11-06 16:57:51 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								   ```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-10-11 03:09:48 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								#### `<array>.CHUNK_SIZE`
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-06 16:57:51 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								The default iteration chunk size.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Note that the smaller this is the more _responsive_  the code is, especially 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								in UI applications but there is a small overhead added per chunk.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Default value: `50` 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-10-10 17:27:00 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-12-08 01:53:40 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								#### `<array>.mapChunks(..)` / `<array>.filterChunks(..)` / `<array>.reduceChunks(..)`
  
						 
					
						
							
								
									
										
										
										
											2020-10-07 03:53:10 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-12-08 01:53:40 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								The `.map(..)` , `.filter(..)`  and `.reduce(..)`  alternatives respectively:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```bnf
							 
						 
					
						
							
								
									
										
										
										
											2020-10-11 03:09:48 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								< array > .mapChunks(< func > ) 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< array > .mapChunks(< chunk-size > , < func > ) 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  -> < promise > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< func > (< item > , < index > , < array > ) 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  -> < new-item > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-12-08 01:53:40 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								```bnf
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< array > .filterChunks(< func > ) 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< array > .filterChunks(< chunk-size > , < func > ) 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  -> < promise > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< func > (< item > , < index > , < array > ) 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  -> < bool > 
							 
						 
					
						
							
								
									
										
										
										
											2020-10-11 03:09:48 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
									
										
										
										
											2020-12-08 01:53:40 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```bnf
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< array > .reduceChunks(< func > , < state > ) 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< array > .mreduceChunks(< chunk-size > , < func > , < state > ) 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  -> < promise > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< func > (< state > , < item > , < index > , < array > ) 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  -> < state > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
									
										
										
										
											2021-04-02 11:25:42 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								<!--  XXX Example  -->  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-12-08 01:53:40 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								All three support chunk handlers in the same way (illustrated on `.mapChunks(..)` ):
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```bnf
							 
						 
					
						
							
								
									
										
										
										
											2020-10-11 03:09:48 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								< array > .mapChunks([< func > , < chunk-handler > ]) 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< array > .mapChunks(< chunk-size > , [< func > , < chunk-handler > ]) 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  -> < promise > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< func > (< item > , < index > , < array > ) 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  -> < new-item > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< chunk-handler > (< chunk > , < result > , < offset > ) 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-12-08 01:53:40 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								The `<chunk-handler>`  gets the completed chunk of data after it is computed 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								but before the timeout.
							 
						 
					
						
							
								
									
										
										
										
											2020-10-11 03:09:48 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-04-02 11:25:42 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								<!--  XXX Example  -->  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-10-07 03:53:10 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-18 06:09:43 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								## `Map`
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```javascript
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								require('ig-types/Map')
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-04-02 11:25:42 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-06-08 18:43:02 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								### `<map>.replaceKey(..)`
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Replace key in map retaining item order
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```bnf
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< map > .replaceKey(< old > , < new > ) 
						 
					
						
							
								
									
										
										
										
											2021-06-09 12:17:42 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								< map > .replaceKey(< old > , < new > , true) 
						 
					
						
							
								
									
										
										
										
											2021-06-08 18:43:02 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    -> < map > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Replace the key without sorting
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```bnf
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< map > .replaceKey(< old > , < new > , false) 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    -> < map > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Note that when sorting large maps this can get expensive.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-18 06:09:43 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								### `<map>.sort(..)`
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-04-03 02:11:02 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Sort `<map>`  keys in-place
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```bnf
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< map > .sort() 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    -> < map > 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-02 11:25:42 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-04-03 02:11:02 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								< map > .sort(< cmp > ) 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    -> < map > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
									
										
										
										
											2021-04-02 11:25:42 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-04-03 02:11:02 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								In the general case this is similar to 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								[`<array>.sort(..)` ](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								with the addition of the [`<array>.sortAs(..)` ](#arraysortas )'s ability to sort 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								as a list
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```bnf
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< map > .sort(< sorted-keys > ) 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    -> < map > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								This is similar to [`<set>.sort(..)` ](#setsort ) and [`Object.sort(..)` ](#objectsort ), 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								see the later for more info.
							 
						 
					
						
							
								
									
										
										
										
											2020-11-18 06:09:43 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-12-08 01:53:40 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-18 06:09:43 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								## `Set`
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```javascript
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								require('ig-types/Set')
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-06-13 13:59:20 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								### `<set>.unite(..)`
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Unite two sets and return the resulting set
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```bnf
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< set > .unite(< other > ) 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    -> < union-set > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								This is a shorthand for `new Set([...<set>, ...<other>])` 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								### `<set>.intersect(..)`
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Intersect two sets and return the intersection set
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```bnf
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< set > .untersect(< other > ) 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    -> < intersection-set > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								### `<set>.subtract(..)`
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Subtract `<other>`  from set and return resulting set
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```bnf
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< set > .subtract(< other > ) 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    -> < sub-set > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								### `<set>.splice(..)`
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								In-place splice a set
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```bnf
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< set > .splice(< from > ) 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< set > .splice(< from > , < count > ) 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< set > .splice(< from > , < count > , ...< items > ) 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    -> < removed > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								This is the same as 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								[`<array>.splice(..)` ](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/splice ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								but without the ability to add more than one instance of an item.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-06-08 16:44:51 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								### `<set>.replace(..)`
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-06-13 13:59:20 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Replace value in set with other value retaining item order (in-place)
							 
						 
					
						
							
								
									
										
										
										
											2021-06-08 16:44:51 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								```bnf
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< set > .replace(< old > , < new > ) 
						 
					
						
							
								
									
										
										
										
											2021-06-09 12:17:42 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								< set > .replace(< old > , < new > , true) 
						 
					
						
							
								
									
										
										
										
											2021-06-08 16:49:11 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    -> < set > 
							 
						 
					
						
							
								
									
										
										
										
											2021-06-08 16:44:51 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-06-08 17:00:55 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Replace the value without sorting
							 
						 
					
						
							
								
									
										
										
										
											2021-06-08 16:49:11 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								```bnf
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< set > .replace(< old > , < new > , false) 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    -> < set > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
									
										
										
										
											2021-06-08 16:44:51 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-06-08 17:00:55 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Note that when sorting large sets this can get expensive.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-06-08 19:21:20 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								### `<set>.replaceAt(..)`
  
						 
					
						
							
								
									
										
										
										
											2021-06-08 17:00:55 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-06-13 13:59:20 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Replace item at position in set retaining order (in-place)
							 
						 
					
						
							
								
									
										
										
										
											2021-06-08 17:00:55 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								```bnf
							 
						 
					
						
							
								
									
										
										
										
											2021-06-09 12:17:42 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								< set > .replaceAt(< index > , < new > ) 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< set > .replaceAt(< index > , < new > , true) 
						 
					
						
							
								
									
										
										
										
											2021-06-08 17:00:55 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    -> < set > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-06-09 12:17:42 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								If `<index>`  is less than `0`  the `<new>`  item will be prepended to `<set>` ,
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								if the `<index>`  is greater than or equal to `<set>.size`  then `<new>`  is 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								appended.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-06-08 17:00:55 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Replace the value at index without sorting
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```bnf
							 
						 
					
						
							
								
									
										
										
										
											2021-06-09 12:17:42 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								< set > .replaceAt(< index > , < new > , false) 
						 
					
						
							
								
									
										
										
										
											2021-06-08 17:00:55 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    -> < set > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-06-09 12:17:42 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Here, if `<index>`  is less than `0`  or greater than or equal to `<set>.size` 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								`<new>`  will always be appended to `<set>` . 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-06-08 17:00:55 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Note that when sorting large sets this can get expensive.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-18 06:09:43 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								### `<set>.sort(..)`
  
						 
					
						
							
								
									
										
										
										
											2020-10-07 16:46:59 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-06-13 13:59:20 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Sort `<set>`  (in-place)
							 
						 
					
						
							
								
									
										
										
										
											2021-04-03 02:11:02 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								```bnf
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< set > .sort() 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    -> < set > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< set > .sort(< cmp > ) 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    -> < set > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								In the general case this is similar to 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								[`<array>.sort(..)` ](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								with the addition of the [`<array>.sortAs(..)` ](#arraysortas )'s ability to sort 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								as a list
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```bnf
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< set > .sort(< sorted-values > ) 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    -> < set > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
									
										
										
										
											2021-04-02 11:25:42 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-04-03 02:11:02 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								This is similar to [`<map>.sort(..)` ](#mapsort ) and [`Object.sort(..)` ](#objectsort ),
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								see the later for more info.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-10-07 03:53:10 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-06-13 13:59:20 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-18 06:09:43 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								## `Date`
  
						 
					
						
							
								
									
										
										
										
											2020-10-07 03:53:10 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-18 06:09:43 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								```javascript
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								require('ig-types/Date')
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-04-02 11:25:42 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-18 06:09:43 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								### `Date.timeStamp(..)`
  
						 
					
						
							
								
									
										
										
										
											2020-10-07 03:53:10 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-04-03 02:11:02 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Generate a timestamp (format: `'YYYYMMDDHHMMSS'` )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```bnf
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Date.timeStamp()
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    -> < timestamp > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Generate a full timestamp, including milliseconds (format: `'YYYYMMDDHHMMSSmmm'` )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```bnf
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Date.timeStamp(true)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    -> < timestamp > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								This is a shorthand to: [`(new Date()).getTimeStamp(..)` ](#dategettimestamp )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								The timestamp is generated from the time of call, for generating timestamps form specific `<date>`  objects see:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								[`<date>.getTimeStamp(..)` ](#dategettimestamp )
							 
						 
					
						
							
								
									
										
										
										
											2021-04-02 11:25:42 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-18 06:09:43 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								### `Date.fromTimeStamp(..)`
  
						 
					
						
							
								
									
										
										
										
											2020-10-07 03:53:10 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-04-03 02:11:02 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Create a `<date>`  from a timestamp
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```bnf
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Date.fromTimeStamp(< timestamp > )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    -> < date > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								This is a shorthand to: [`(new Date()).setTimeStamp(<timestamp>)` ](#datesettimestamp )
							 
						 
					
						
							
								
									
										
										
										
											2021-04-02 11:25:42 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-18 06:09:43 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								### `Date.str2ms(..)`
  
						 
					
						
							
								
									
										
										
										
											2020-10-07 16:46:59 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-04-02 11:25:42 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Convert a string describing a time period into milliseconds.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```bnf
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Date.str2ms(< str > )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    -> < number > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Examples:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```javascript
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// time units (d/h/m/s/ms) and their variants...
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								var a = Date.str2ms('3 seconds') // -> 3000
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								var b = Date.str2ms('0.1h') // -> 360000
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// time period (DD:HH:MM:SS:mmm)...
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								var c = Date.str2ms('00:20:001') // -> 20001
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								var d = Date.str2ms('1:3') // -> 63000
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Note that time periods are seconds-based by default unless it contains three 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								digits then it defaults to milliseconds:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```javascript
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// least significant unit is seconds by default...
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								var e = Date.str2ms(':3') // -> 3000
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// when the least significant unit contains 3 digits it is read as ms...
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								var f = Date.str2ms(':030') // -> 30
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Supported formats:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```bnf
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< str >  ::= 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    < milliseconds > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    | < seconds > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    | < minutes > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    | < hours > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    | < days > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    | < period > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< milliseconds >  ::= 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    < number > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    | < number > ms
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    | < number > m[illi][-]s[ec[ond[s]]]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< seconds >  ::= 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    < number > s
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    | < number > s[ec[ond[s]]]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< seconds >  ::= 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    < number > m
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    | < number > m[in[ute[s]]]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< seconds >  ::= 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    < number > h
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    | < number > h[our[s]]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< seconds >  ::= 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    < number > d
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    | < number > d[ay[s]]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< period >  ::=  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    [[[DD:]HH:]MM]:SS[:mmm]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    | [[[[DD:]HH:]MM]:SS]:mmm
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-18 06:09:43 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								### `<date>.toShortDate(..)`
  
						 
					
						
							
								
									
										
										
										
											2020-10-07 03:53:10 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-04-03 02:11:02 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Generate a short date string from `<date>`  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								(format: `'YYYY-MM-DD HH:MM:SS'` )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```bnf
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< date > .toShortDate() 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    -> < short-date > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Generate a short date string including milliseconds from `<date>`  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								(format: `'YYYY-MM-DD HH:MM:SS:mmm'` )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```bnf
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< date > .toShortDate(true) 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    -> < short-date > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Note that `<short-date>`  is directly parseable by `new Date(..)` 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```javascript
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								var a = (new Date()).toShortDate(true)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// parse the < short-date >  and generate a new short date from it...
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								var b = (new Date(a)).toShortDate(true)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								a == b // -> true
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
									
										
										
										
											2021-04-02 11:25:42 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-18 06:09:43 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								### `<date>.getTimeStamp(..)`
  
						 
					
						
							
								
									
										
										
										
											2020-10-07 03:53:10 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-04-03 02:11:02 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Generate a timestamp from `<date>` 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								(format `'YYYYMMDDHHMMSS'` )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```bnf
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< date > .getTimeStamp() 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    -> < timestamp > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
									
										
										
										
											2021-04-02 11:25:42 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-04-03 02:11:02 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Generate a timestamp from `<date>`  including milliseconds 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								(format `'YYYYMMDDHHMMSSmmm'` )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```bnf
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< date > .getTimeStamp(true) 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    -> < timestamp > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
									
										
										
										
											2021-04-02 11:25:42 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-10-07 03:53:10 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-04-03 02:11:02 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								### `<date>.setTimeStamp(..)`
  
						 
					
						
							
								
									
										
										
										
											2021-04-02 11:25:42 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-04-03 02:11:02 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Update a `<date>`  from a timestamp
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```bnf
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< date > .setTimeStamp(< timestamp > ) 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    -> < date > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
									
										
										
										
											2021-04-02 11:25:42 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-10-07 03:53:10 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-18 06:09:43 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								## `String`
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```javascript
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								require('ig-types/String')
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
									
										
										
										
											2020-10-07 03:53:10 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-18 06:09:43 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								### `<string>.capitalize()`
  
						 
					
						
							
								
									
										
										
										
											2020-10-07 03:53:10 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-04-05 14:07:01 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Capitalize the first character of a string
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```bnf
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< string > .capitalize() 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    -> < string > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
									
										
										
										
											2021-04-02 11:25:42 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-12-17 18:55:28 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								### `<string>.indent(..)`
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-04-05 14:07:01 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Indent each line in `<string>`  by `<size>`  spaces
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```bnf
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< string > .indent(< size > ) 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    -> < string > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
									
										
										
										
											2021-04-02 11:25:42 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-04-05 14:07:01 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Indent/prepend each line in `<string>`  by the `<prefix>`  string
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```bnf
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< string > .indent(< prefix > ) 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    -> < string > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
									
										
										
										
											2021-04-02 11:25:42 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-10-07 03:53:10 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-18 06:09:43 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								## `RegExp`
  
						 
					
						
							
								
									
										
										
										
											2020-10-07 03:53:10 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-18 06:09:43 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								```javascript
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								require('ig-types/RegExp')
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
									
										
										
										
											2020-10-07 03:53:10 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-04-02 11:25:42 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-18 06:09:43 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								### `RegExp.quoteRegExp(..)`
  
						 
					
						
							
								
									
										
										
										
											2020-10-07 03:53:10 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-04-05 14:07:01 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Quote regexp reserved characters in a string
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```bnf
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								RegExp.quoteRegExp(< str > )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    -> < str > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								This is mainly used to quote strings to be matched as-is within a regular expression.
							 
						 
					
						
							
								
									
										
										
										
											2021-04-02 11:25:42 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-10-07 03:53:10 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-18 06:09:43 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								## `Promise`
  
						 
					
						
							
								
									
										
										
										
											2020-10-07 03:53:10 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-18 06:09:43 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								```javascript
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								require('ig-types/Promise')
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								or
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```javascript
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								var promise = require('ig-types/Promise')
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
									
										
										
										
											2020-10-07 03:53:10 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-10 03:04:04 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-04-06 14:27:48 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								### Interactive promises
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								_Interactive promises_ can be sent messages and then handle them.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```javascript
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								var printer = Promise.interactive(function(resolve, reject, onmessage){
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    var buf = []
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    var state = 'pending'
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    onmessage(function(type, ...args){
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        type == 'flush' ?
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            (buf = buf
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                .filter(function([type, state, ...args]){
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    console[type ](`(${ state } ):`, ...args) }))
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        : type == 'close' ?
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            (resolve(...args), 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                state = 'resolved')
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        : buf.push([type, state, ...args]) }) })
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								printer
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    .send('log', 'some message...')
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    .send('warn', 'some warning...')
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    .send('flush')
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    .send('close')
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Note that message handling is independent of promise state, so in the above case 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-07 03:17:02 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								we can still populate the buffer and _flush_  it even if the promise is resolved
							 
						 
					
						
							
								
									
										
										
										
											2021-04-06 14:27:48 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								```javascript
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								printer
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    .send('log', 'some other message...')
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    .send('flush')
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-04-11 00:09:20 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								If the user wants to handle messages differently (ignore for example) after the
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								promise is finalized it is their responsibility 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								(see: [`<onmessage>(..)` ](#promiseinteractive ) for more info)
							 
						 
					
						
							
								
									
										
										
										
											2021-04-06 14:27:48 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-04-07 03:17:02 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-04-06 14:27:48 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								#### `Promise.interactive(..)`
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Create and interactive promise
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```bnf
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Promise.interactive(< handler > )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    -> < promise-inter > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								The `<handler>`  accepts one additional argument, compared to the `Promise(..)` 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								handler, `<onmessage>` , used to register message handlers.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```bnf
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< handler > (< resolve > , < reject > , < onmessage > ) 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< onmessage > (< message-handler > ) 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-04-07 03:32:23 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Remove `<message-handler>` 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```bnf
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< onmessage > (< message-handler > , false) 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Remove all handlers
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```bnf
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< onmessage > (false) 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-04-06 14:27:48 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								`<message-handler>`  is called when a message is sent via  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								[`<promise-inter>.send()` ](#promise-intersend ).
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								#### `<promise-inter>.send(..)`
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Send a message to an interactive promise
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```bnf
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< promise-inter > .send() 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< promise-inter > .send(...) 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    -> < promise-inter > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Sending a message triggers message handlers registered via `<onmessage>(..)`  
							 
						 
					
						
							
								
									
										
										
										
											2021-04-07 03:17:02 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								passing each handler the arguments.
							 
						 
					
						
							
								
									
										
										
										
											2021-04-06 14:27:48 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-04-07 14:47:25 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								#### `<promise-inter>.then(..)`
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-04-13 05:26:17 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Extended `.then(..)`  implementation.
							 
						 
					
						
							
								
									
										
										
										
											2021-04-07 14:47:25 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								See [`<promise-iter>.then(..)` ](#promise-iterthen--promise-itercatch--promise-iterfinally ) for details.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-04-06 14:27:48 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-18 06:09:43 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								### Cooperative promises
  
						 
					
						
							
								
									
										
										
										
											2020-11-03 05:22:29 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-04-07 14:47:25 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								A _cooperative promise_  is one that can be finalized externally/cooperatively.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-04-19 07:46:29 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								This can be useful for breaking recursive dependencies between promises or when
							 
						 
					
						
							
								
									
										
										
										
											2021-04-07 14:47:25 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								it is simpler to thread the result receiver promise down the stack than building 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								a promise stack and manually threading the result up.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-04-17 15:07:20 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Example:
							 
						 
					
						
							
								
									
										
										
										
											2021-04-07 14:47:25 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								```javascript
							 
						 
					
						
							
								
									
										
										
										
											2021-04-17 15:07:20 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								// NOTE: implementing this via Promise.any(..) would also require implementing a 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-19 07:46:29 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								//      way to stop the "workers" after the result is found...
							 
						 
					
						
							
								
									
										
										
										
											2021-04-17 15:07:20 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								async function controller(trigger){
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    while(!trigger.isSet)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        // do things...
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        trigger.isSet
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            || trigger.set(result) } }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								async function controlled(trigger){
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    // do things independently of trigger...
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    trigger
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        .then(function(){
							 
						 
					
						
							
								
									
										
										
										
											2021-04-18 10:41:37 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            // do things after trigger...
							 
						 
					
						
							
								
									
										
										
										
											2021-04-17 15:07:20 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        }) }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								var t = Promise.cooperative()
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// multiple cooperative controllers competing to create a result...
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								controller(t)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								controller(t)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								controller(t)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// ...
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// prepare and process result...
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// NOTE: calling .then() here is completely optional and done out of role
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								//      hygene -- isolating cooperative API from the client...
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								controlled(t.then())
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// ...
							 
						 
					
						
							
								
									
										
										
										
											2021-04-07 14:47:25 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-06-04 09:38:49 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Note that this functionally can be considered a special-case of an 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-07 14:47:25 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								[interactive promise ](#interactive-promises ), but in reality they are two 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								different implementations, the main differences are:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								-  _Cooperative promise_ constructor does not need a resolver function, 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								-  _Cooperative promises_ do not the implement `.send(..)`  API. 
						 
					
						
							
								
									
										
										
										
											2021-04-06 14:27:48 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-04-07 14:47:25 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Note that implementing _Cooperative promises_  on top of _Interactive promises_  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								cleanly, though feeling more _"beautiful"_ , would be more complex than the 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								current standalone implementation, as it would require both implementing 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								the `.set(..)`  API/logic _and_  active encapsulation of the message API.
							 
						 
					
						
							
								
									
										
										
										
											2021-04-02 11:25:42 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-04-07 14:47:25 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								#### `Promise.cooperative()`
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-04-09 02:26:34 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Create a cooperative promise
							 
						 
					
						
							
								
									
										
										
										
											2021-04-07 14:47:25 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								```bnf
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Promise.cooperative()
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    -> < promise-coop > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
									
										
										
										
											2020-11-03 05:22:29 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-04-02 11:25:42 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-18 06:09:43 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								#### `<promise-coop>.set(..)`
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-04-09 02:26:34 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Resolve `<promise-coop>`  with `<value>` 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-08 22:04:29 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								```bnf
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< promise-coop > .set(< value > ) 
						 
					
						
							
								
									
										
										
										
											2021-04-09 02:26:34 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								< promise-coop > .set(< value > , true) 
						 
					
						
							
								
									
										
										
										
											2021-04-08 22:04:29 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    -> < promise-coop > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-04-09 02:26:34 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								If `<value>`  is a promise, then `<promise-coop>`  will be bound to its state, i.e.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								resolved if `<value>`  is resolved and rejected if it is rejected with the same
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								values.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Reject `<promise-coop>`  with `<value>` 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```bnf
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< promise-coop > .set(< value > , false) 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    -> < promise-coop > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Calling `.set(..)`  will set `.isSet`  to `true` .
							 
						 
					
						
							
								
									
										
										
										
											2021-04-02 11:25:42 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-18 06:09:43 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								#### `<promise-coop>.isSet`
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-04-09 02:26:34 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Property representing if the cooperative promise was _set_  / `.set(..)`  was 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								called (value is `true` ) or no (`false` ).
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								This property is read-only.
							 
						 
					
						
							
								
									
										
										
										
											2021-04-02 11:25:42 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-04-07 14:47:25 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								#### `<promise-coop>.then(..)`
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-04-13 05:26:17 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Extended `.then(..)`  implementation.
							 
						 
					
						
							
								
									
										
										
										
											2021-04-07 14:47:25 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								See [`<promise-iter>.then(..)` ](#promise-iterthen--promise-itercatch--promise-iterfinally ) for details.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-18 06:09:43 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								### Promise iteration
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								An _iterable promise_  is on one hand very similar to `Promise.all(..)`  in that it
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								generally takes a list of values each could be either an explicit value or a 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-21 13:45:26 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								promise, and it is similar to a _generator_  in that it allows iteration over the 
							 
						 
					
						
							
								
									
										
										
										
											2020-11-18 06:09:43 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								contained values and chaining of operations but unlike `Promise.all(..)`  this 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-21 13:45:26 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								iteration occurs depth-first instead of breadth first.
							 
						 
					
						
							
								
									
										
										
										
											2020-11-18 06:09:43 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-06-02 12:05:37 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								One can think of _promise iterators_  vs. _generators_  as the former being 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								internally controlled and asynchronous while the later being externally
							 
						 
					
						
							
								
									
										
										
										
											2020-11-18 06:59:56 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								controlled and synchronous.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-18 06:09:43 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Here is a traditional example using `Promise.all(..)` :
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```javascript
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								var p = Promise.all([ .. ])
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    // this will not execute until ALL the inputs resolve...
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    .then(function(lst){
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return lst
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								          .filter(function(e){
							 
						 
					
						
							
								
									
										
										
										
											2021-04-21 13:45:26 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								              // ...
							 
						 
					
						
							
								
									
										
										
										
											2020-11-18 06:09:43 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								          })
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								          // this will not run until ALL of lst is filtered...
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								          .map(function(e){
							 
						 
					
						
							
								
									
										
										
										
											2021-04-21 13:45:26 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								              // ...
							 
						 
					
						
							
								
									
										
										
										
											2020-11-18 06:09:43 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								          }) })
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-04-21 13:45:26 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								And a _promise iterator_ :
							 
						 
					
						
							
								
									
										
										
										
											2020-11-18 06:09:43 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								```javascript
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								var p = Promise.iter([ .. ])
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    // each element is processed as soon as it is ready disregarding of its order
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    // in the input array...
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    .filter(function(e){
							 
						 
					
						
							
								
									
										
										
										
											2021-04-21 13:45:26 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        // ...
							 
						 
					
						
							
								
									
										
										
										
											2020-11-18 06:09:43 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    })
							 
						 
					
						
							
								
									
										
										
										
											2021-04-21 13:45:26 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    // items reach here as soon as they are returned by the filter stage handler...
							 
						 
					
						
							
								
									
										
										
										
											2020-11-18 06:09:43 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    .map(function(e){
							 
						 
					
						
							
								
									
										
										
										
											2021-04-21 13:45:26 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        // ...
							 
						 
					
						
							
								
									
										
										
										
											2020-11-18 06:09:43 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    })
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    // .then(..) explicitly waits for the whole list of inputs to resolve...
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    .then(function(lst){
							 
						 
					
						
							
								
									
										
										
										
											2021-04-21 13:45:26 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        // ...
							 
						 
					
						
							
								
									
										
										
										
											2020-11-18 06:09:43 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    })
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								This approach has a number of advantages:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								-  items are processed as soon as they are available without waiting for the  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  slowest promise on each level to resolve
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								-  simpler and more intuitive code 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								And some disadvantages:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								-  item indexes are unknowable until all the promises resolve. 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-06-04 10:01:50 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Calling each of the `<promise-iter>`  methods will return a new and unresolved 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								promise, even if the original is resolved.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								If all values are resolved the `<promise-iter>`  will resolve on the next 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								execution frame.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-06-09 11:12:39 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								There are two types of iterator methods here, both are transparent but different
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								in how they process values:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								-  *Parallel methods*   
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  These handle elements as soon as they are available even if the parent promise
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  is not yet resolved.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  <!--  XXX list  --> 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								-  *Proxies* 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  These methods simply wait for the main promise to resolve and then call the
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  appropriate method on the result.
							 
						 
					
						
							
								
									
										
										
										
											2022-06-10 01:24:06 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  <!--  XXX list + mark definitions as "(proxy)"  --> 
							 
						 
					
						
							
								
									
										
										
										
											2022-06-09 11:12:39 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-04-21 13:45:26 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								<!--  
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								XXX should we support generators as input?
							 
						 
					
						
							
								
									
										
										
										
											2021-04-22 14:47:38 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    ...not sure about the control flow direction here, on one hand the generator
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    should be unwound by the client (not sure how to do this within a promise) on 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    the other hand...
							 
						 
					
						
							
								
									
										
										
										
											2021-04-23 12:06:12 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    ...not sure if it is possible/correct to control the flow upstream in a 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    promise chain...
							 
						 
					
						
							
								
									
										
										
										
											2021-04-25 23:02:06 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    ...might be a good idea to at least provide some means to control flow up
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    the chain, for instance to abort execution...
							 
						 
					
						
							
								
									
										
										
										
											2021-04-21 13:45:26 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								XXX should we support infinite generators as input?
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								-->
							 
						 
					
						
							
								
									
										
										
										
											2020-11-18 06:09:43 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								#### `Promise.iter(..)` / `promise.IterablePromise(..)`
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Create an _iterable promise_ 
							 
						 
					
						
							
								
									
										
										
										
											2022-06-02 12:05:37 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-04-14 15:51:18 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								```bnf
							 
						 
					
						
							
								
									
										
										
										
											2020-11-18 06:09:43 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Promise.iter(< array > )
							 
						 
					
						
							
								
									
										
										
										
											2022-06-02 12:05:37 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Promise.iter(< promise > )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    -> < promise-iter > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								#### `<promise>.iter()`
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-06-03 21:23:23 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Wrap a promise in an promise iterator. 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-06-02 12:05:37 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								```bnf
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< promise > .iter() 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    -> < promise-iter > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-06-03 21:23:23 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								If `<promise>`  resolves to a non-array value it will be treated as a single 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								element, otherwise the array will be iterated over.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-06-02 12:05:37 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								#### `<promise-iter>.iter()`
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-06-03 21:23:23 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Return a shallow copy of the current promise iterator.
							 
						 
					
						
							
								
									
										
										
										
											2022-06-02 12:05:37 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```bnf
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< promise-iter > .iter() 
						 
					
						
							
								
									
										
										
										
											2021-04-29 14:28:18 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    -> < promise-iter > 
							 
						 
					
						
							
								
									
										
										
										
											2020-11-18 06:09:43 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
									
										
										
										
											2021-04-02 11:25:42 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-18 06:09:43 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								#### `<promise-iter>.map(..)` / `<promise-iter>.filter(..)` / `<promise-iter>.reduce(..)`
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-05-02 02:33:03 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Methods similar but not fully equivalent to `Array` 's 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								[`.map(..)` ](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map ), 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								[`.filter(..)` ](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter ),
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								and [`.reduce(..)` ](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduce )
							 
						 
					
						
							
								
									
										
										
										
											2021-04-29 14:28:18 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								```bnf
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< promise-iter > .map(< handler > ) 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    -> < promise-iter > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-05-02 02:33:03 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								< handler > (< elem > ) 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    -> < elem > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```bnf
							 
						 
					
						
							
								
									
										
										
										
											2021-04-29 14:28:18 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								< promise-iter > .filter(< handler > ) 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    -> < promise-iter > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< handler > (< elem > ) 
						 
					
						
							
								
									
										
										
										
											2021-05-02 02:33:03 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    -> < bool > 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-29 14:28:18 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```bnf
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< promise-iter > .reduce(< handler > , < state > ) 
						 
					
						
							
								
									
										
										
										
											2022-06-02 12:05:37 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    -> < promise > 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-29 14:28:18 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< handler > (< state > , < elem > ) 
						 
					
						
							
								
									
										
										
										
											2021-05-02 02:33:03 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    -> < state > 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-29 14:28:18 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Note that these are different to `Array` 's equivalents in some details: 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								-  `<handler>`  is _not_  called in the order of element occurrence but rather  
						 
					
						
							
								
									
										
										
										
											2022-06-04 10:01:50 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    in the order of elements are resolved/ready.
							 
						 
					
						
							
								
									
										
										
										
											2021-04-29 14:28:18 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								-  `<handler>`  does not get either the element _index_  or the _container_ .   
						 
					
						
							
								
									
										
										
										
											2022-06-04 10:01:50 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    this is because in _out-of-order_  and _depth-first_  execution the 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    index is _unknowable_  and the container is a promise/black-box.
							 
						 
					
						
							
								
									
										
										
										
											2021-04-29 14:28:18 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-06-04 10:01:50 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								This is especially critical for `.reduce(..)`  as the iteration in an order
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								different from the order of elements _can_  affect actual result if this is 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								not expected.
							 
						 
					
						
							
								
									
										
										
										
											2022-06-02 12:05:37 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								`.reduce(..)`  is also a bit different here in that it will return a basic  
						 
					
						
							
								
									
										
										
										
											2022-06-04 10:01:50 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								`<promise>`  rather than an iterable promise object as we can't know what  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								will it will reduce to.
							 
						 
					
						
							
								
									
										
										
										
											2022-06-02 12:05:37 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-06-04 10:01:50 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Note that since `.reduce(..)`  handler's execution order can not be known,
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								there is no point in implementing `.reduceRigth(..)` .
							 
						 
					
						
							
								
									
										
										
										
											2022-06-02 12:05:37 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-04-02 11:25:42 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-18 06:09:43 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								#### `<promise-iter>.flat(..)`
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-04-29 14:28:18 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								```bnf
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< promise-iter > .flat() 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< promise-iter > .flat(< depth > ) 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    -> < promise-iter > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
									
										
										
										
											2021-04-02 11:25:42 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-04-29 14:28:18 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								This is similar to [`<array>.flat(..)` ](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/flat ) see it for more info.
							 
						 
					
						
							
								
									
										
										
										
											2021-04-02 11:25:42 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-18 06:09:43 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-06-03 21:23:23 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								#### `<promise-iter>.reverse()`
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```bnf
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< promise-iter > .reverse() 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    -> < promise-iter > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-06-04 03:01:54 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								This is deferent from `<array>.reverse()`  in that it will _not_  reverse in-place, 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								but rather a _reversed copy_  will be created.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								This is similar to [`<array>.reverse()` ](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reverse ) see it for more info.
							 
						 
					
						
							
								
									
										
										
										
											2022-06-03 21:23:23 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-06-04 03:10:49 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								#### `<promise-iter>.concat(..)`
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```bnf
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< promise-iter > .concat(< other > ) 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    -> < promise-iter > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								This is similar to [`<array>.concat(..)` ](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/concat ) see it for more info.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								#### `<promise-iter>.push(..)` / `<promise-iter>.unshift(..)`
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```bnf
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< promise-iter > .push(< elem > ) 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    -> < promise-iter > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< promise-iter > .unshift(< elem > ) 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    -> < promise-iter > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								These are similar to [`<array>.push(..)` ](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/push ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								and [`<array>.unshift(..)` ](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/unshift ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								see them for more info.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-06-11 11:36:13 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								#### `<promise-iter>.at(..)` / `<promise-iter>.first()` / `<promise-iter>.last()`
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-06-12 10:28:01 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Proxies to the appropriate array methods with a special-case: when getting elements 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								at positions `0`  or `-1`  (i.e. `.first()`  / `.last()` ) these _can_  resolve before the
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								parent `<promise-iter>` .
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-06-11 11:36:13 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								XXX
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-27 14:50:59 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								#### `<promise-iter>.join(..)`
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								XXX
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-06-13 22:48:07 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								#### `<promise-iter>.some(..)` / `<promise-iter>.find(..)`
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```bnf
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< promise-iter > .some(< func > ) 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    -> < promise > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< promise-iter > .find(< func > ) 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    -> < promise > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								The main difference between `.some(..)`  and `.find(..)`  is in that the `<promise>` 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								returned from the former will resolve to either `true`  or `false` , and in the later
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								to the found value or `undefined` .
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								`.find(..)`  supports an additional argument that controls what returned `<promise>`  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								is resolved to...
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```bnf
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< promise-iter > .find(< func > ) 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< promise-iter > .find(< func > , 'value') 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    -> < promise > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< promise-iter > .find(< func > , 'bool') 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    -> < promise > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< promise-iter > .find(< func > , 'result') 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    -> < promise > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								-  `value`  (default)   
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  resolve to the stored value if found and `undefined`  otherwise.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								-  `bool`    
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  resolve to `true`  if the value is found and `false`  otherwise, this is how 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  `.some(..)`  is impelemnted.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								-  `result`    
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  resolve to the return value of the test `<func>` .
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								These are similar to [`<array>.some(..)` ](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/some ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								and [`<array>.find(..)` ](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/find ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								see them for more info.
							 
						 
					
						
							
								
									
										
										
										
											2022-06-11 11:36:13 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-06-11 11:55:44 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								#### Array proxy methods returning `<promise-iter>`
  
						 
					
						
							
								
									
										
										
										
											2022-06-11 11:36:13 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-06-11 11:55:44 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								-  `<promise-iter>.sort(..)`  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								-  `<promise-iter>.slice(..)`  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								-  `<promise-iter>.entries()`  / `<promise-iter>.keys()`  / `<promise-iter>.values()`   
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								These methods are proxies to the appropriate array methods.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```bnf
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< promise-iter > .< method > (..) 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    -> < promise-iter > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								These methods need the parent `<promise-iter>`  to resolve before resolving themselves.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								XXX links...
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								#### Array proxy methods returning a `<promise>`
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								-  `<promise-iter>.indexOf(..)`   
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								-  `<promise-iter>.includes(..)`   
						 
					
						
							
								
									
										
										
										
											2022-06-13 22:48:07 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								-  `<promise-iter>.every(..)`  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								-  `<promise-iter>.findIndex(..)`  
						 
					
						
							
								
									
										
										
										
											2022-06-11 11:55:44 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								These methods are proxies to the appropriate array methods.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```bnf
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< promise-iter > .< method > (..) 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    -> < promise > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								These methods need the parent `<promise-iter>`  to resolve before resolving themselves.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Since the equivalent array methods do not return iterables these will return a basic
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								(non-iterable) `<promise>` .
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								XXX links...
							 
						 
					
						
							
								
									
										
										
										
											2022-06-11 11:36:13 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-18 06:09:43 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								#### `<promise-iter>.then(..)` / `<promise-iter>.catch(..)` / `<promise-iter>.finally(..)`
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-04-13 05:26:17 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								An extension to
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								[`<promise>.then(..)` API ](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/then )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								this adds the ability to pass no arguments
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```bnf
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< promise-iter > .then() 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    -> < promise > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
									
										
										
										
											2021-04-02 11:25:42 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-04-13 05:26:17 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								This will return a generic promise wrapper passing through the results as-is. This 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								can be useful to hide the extended promise API from further code.
							 
						 
					
						
							
								
									
										
										
										
											2021-04-07 14:47:25 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-06-13 22:48:07 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								#### `promise.IterablePromise.STOP` / `promise.IterablePromise.STOP(..)`
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								A special object that when thrown from a function/promise handler will stop 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								further iteration.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								This is `undefined`  until the `ig-types/Array`  module is loaded.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								For more info see: [Stopping the iteration ](#stopping-the-iteration ) below, and
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								[the 'Array' STOP section ](#arraystop--arraystop )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-04-02 11:25:42 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-18 06:09:43 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								#### Advanced handler
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-12-08 01:53:40 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								```bnf
							 
						 
					
						
							
								
									
										
										
										
											2022-06-04 09:30:50 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Promise.iter(< block > , < handler > )
							 
						 
					
						
							
								
									
										
										
										
											2020-11-18 06:09:43 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    -> < iterable-promise > 
							 
						 
					
						
							
								
									
										
										
										
											2022-06-04 09:30:50 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
									
										
										
										
											2020-11-18 06:09:43 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-06-04 09:30:50 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								The `<handler>`  will get passed each resolved `<value>`  of the input `<block>`  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								as soon as it's available/resolved.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								The `<handler>`  return value is unwrapped into the resulting array, allowing
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								each call to both remove elements (i.e. returning `[]` ) from the resulting 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								`<block>`  as well as insert multiple items (by returning an array of items). 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								<!--  XXX returning promises from handler needs to be documented/tested...  -->  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```bnf
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< handler > (< value > ) 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    -> []
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    -> [ < elem > , .. ]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    -> < non-array > 
							 
						 
					
						
							
								
									
										
										
										
											2020-11-18 06:09:43 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```bnf
							 
						 
					
						
							
								
									
										
										
										
											2022-06-04 09:30:50 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								< block >  ::=  
						 
					
						
							
								
									
										
										
										
											2020-11-18 06:09:43 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    []
							 
						 
					
						
							
								
									
										
										
										
											2022-06-04 09:30:50 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    | [ < elem > , .. ]
							 
						 
					
						
							
								
									
										
										
										
											2020-11-18 06:09:43 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-06-04 09:30:50 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								< elem >  ::=  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    < value > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    | < promise > (< value > )
							 
						 
					
						
							
								
									
										
										
										
											2020-11-18 06:09:43 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Example:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```javascript
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								var p = Promise.iter(
							 
						 
					
						
							
								
									
										
										
										
											2022-06-04 09:30:50 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        [1, 2, 3, Promise.resolve(4), [5, 6]], 
							 
						 
					
						
							
								
									
										
										
										
											2020-11-18 06:09:43 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        function(elem){
							 
						 
					
						
							
								
									
										
										
										
											2022-06-04 09:34:10 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            // duplicate even numbers...
							 
						 
					
						
							
								
									
										
										
										
											2020-11-18 06:09:43 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            return elem % 2 == 0 ?
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    [elem, elem]
							 
						 
					
						
							
								
									
										
										
										
											2022-06-04 09:34:10 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                // return arrays as-is...
							 
						 
					
						
							
								
									
										
										
										
											2020-11-18 06:09:43 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                : elem instanceof Array ?
							 
						 
					
						
							
								
									
										
										
										
											2022-06-04 09:30:50 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                    [elem]
							 
						 
					
						
							
								
									
										
										
										
											2022-06-04 09:34:10 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                // remove other elements...
							 
						 
					
						
							
								
									
										
										
										
											2020-11-18 06:09:43 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                : [] })
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    .then(function(lst){
							 
						 
					
						
							
								
									
										
										
										
											2022-06-04 09:30:50 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        console.log(lst) }) // -> [2, 2, 4, 4, [5, 6]]
							 
						 
					
						
							
								
									
										
										
										
											2020-11-18 06:09:43 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
									
										
										
										
											2020-11-03 05:22:29 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-06-13 22:48:07 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								#### Stopping the iteration
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Like the [`Array` ](#arraystop--arraystop ) module, this support throwing `STOP`  to 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								stop iteration. As we uses [`.smap(..)` ](#arraysmap--arraysfilter--arraysreduce--arraysforeach ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								stopping support is supported if `ig-types/Array`  module is loaded.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```javascript
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								require('ig-types/Array')
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								This is also different semantically, as promise iteration can happen out of order,
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								stopping affects the order of processing and not order of the input array with one exception: promises already created can not be stopped in `JavaScript` .
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Any handler function passed to a `<promise-iter>`  method can `throw`  a STOP.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								For more details see: [the 'Array' STOP section ](#arraystop--arraystop )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-10-07 03:53:10 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-05-30 12:12:00 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								### Promise proxies
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								_Promise proxies_ generate a set of prototype methods returning promises that when the parent promise is resolved will resolve to a specific method call.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Example:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```javascript
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								var o = {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    method: function(...args){
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        console.log('method:', ...args)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    },
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								var p = Peomise.cooperative().as(o)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								p.method(1, 2, 3) // returns a promise...
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// ...
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// resolving a promise will trigger all the proxy emthod execution, so 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// here 'method: 1, 2, 3' will get printed...
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								p.set(o)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								#### `<promise>.as(..)`
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Create a promise proxy
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```bnf
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< promise > .as(< object > ) 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< promise > .as(< constructor > ) 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    -> < promise-proxy > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								A proxy promise will be populated with proxy methods to all the methods of the `<object>`  or `<constructor>.prototype` .
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								#### `<promise-proxy>.<method>(..)`
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								When `<promise>`  resolves, call the `.<method>(..)`  on the resolved value.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```bnf
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< promise-proxy > .< method > (..) 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    -> < method-promise > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								`<method-promise>`  will resolve the the return value of the `<method>`  when  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								the main `<promise>`  is resolved.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-10 03:25:00 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								## Generator extensions and utilities
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```javascript
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								var generator = require('ig-types/generator')
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								### The basics
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-03-24 18:57:02 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								The _generator_  hierarchy in JavaScript is a bit complicated.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Consider the following:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```javascript
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// generator constructor function...
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								var Iter = function*(L){
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    for(var e of L){
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        yield e }}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// generator instance...
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								var iter = Iter([1, 2, 3])
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								We can test that `iter`  is an instance of `Iter` :
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```javascript
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								iter instanceof Iter // -> true
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-05-03 02:56:23 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Note that there is no generator constructor constructor or _meta-generator_ , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								i.e. `Iter`  is created syntactically and not constructed via a `new`  _constructor_ .
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-04-01 02:30:36 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Due to the three level structure of generators we use a slightly different 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								terminology to reference different levels of API's:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								-  `Generator`  - the generator meta-constructor.   
						 
					
						
							
								
									
										
										
										
											2021-05-03 02:56:23 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    This is a constructor that is used to create/prototype `<Generator>` 's, i.e.
							 
						 
					
						
							
								
									
										
										
										
											2021-04-01 02:30:36 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    generator constructors.  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    `Generator`  is mainly used for `instanceof`  checks, but can be used as a 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    prototype for extending generators.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								-  `<Generator>`  - the generator constructor.   
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    This is the product of either a `Generator`  meta-constructor or a 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    `function*(..){ .. }`  statement.  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    In the above example `Iter`  is a generator constructor.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								-  `<generator>`  - the generator instance.   
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    Generator instances are created by calling a `<Generator>`  / generator 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    constructor.  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    In the above example `iter`  is a generator instance.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-05-29 15:17:06 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Iterators and generators are similar but not the same. Some objects like `Array` 's, 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								`Map` 's and `Set` 's provide a number of generic iterators that are not implemented  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								as generators. These objects are also extended by `ig-types/generator`  to match the 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								`<generator>`  object API defined below. 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-03-24 18:57:02 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								#### `generator.Generator`
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-04-01 02:30:36 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Exposes the _hidden_  JavaScript generator meta-constructor.
							 
						 
					
						
							
								
									
										
										
										
											2021-03-24 18:57:02 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-05-03 02:56:23 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								This is similar to the JavaScript's
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								[`Function` ](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function ) constructor
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```javascript
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								var g = generator.Generator(`
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    yield 123
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    yield 321 `)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// prints 123 then 321...
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								for(var e of g()){
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    console.log(e.value) }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								This can be used to test if a function is a _generator constructor_ 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-24 18:57:02 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								```javascript
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Iter instanceof generator.Generator // -> true
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-05-03 02:56:23 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Note that currently in JavaScript there is no _built-in_  way to test if a 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								constructor/function, `Iter`  in this case, is a _generator_  constructor.
							 
						 
					
						
							
								
									
										
										
										
											2021-03-24 18:57:02 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-10 03:25:00 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								#### `generator.iter(..)`
  
						 
					
						
							
								
									
										
										
										
											2020-11-10 03:04:04 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-03-24 18:57:02 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Generic generator wrapper
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```bnf
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								generator.iter()
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    -> < generator > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								generator.iter(< iterable > )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    -> < generator > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Example:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```javascript
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								for(var i of generator.iter([1, 2, 3])){
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    console.log(i) }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								The following are equivalent:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```javascript
							 
						 
					
						
							
								
									
										
										
										
											2021-03-31 16:01:52 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								var a = generator.iter()
							 
						 
					
						
							
								
									
										
										
										
											2021-03-24 18:57:02 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-03-31 16:01:52 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								var b = new generator.Generator()
							 
						 
					
						
							
								
									
										
										
										
											2021-03-24 18:57:02 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-05-04 14:59:36 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								But `Generator()`  takes no arguments and thus can not be used as a wrapper 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								while `.iter(..)`  is designed to accept an iterable value like an array object.
							 
						 
					
						
							
								
									
										
										
										
											2021-03-24 18:57:02 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-10 03:04:04 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-05-25 17:21:40 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								#### `generator.STOP`
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								<!--  XXX  -->  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-10 03:04:04 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								### Generator instance iteration
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-03-25 02:59:15 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								This is a set of `Array` -like iterator methods that enable chaining of 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-25 14:40:51 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								generators and `Promise` -like API to handle the generated results. 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-25 02:59:15 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-05-04 14:59:36 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Chained generators handle items depth-first, i.e. the items are passed as they 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								are yielded down the generator chain.
							 
						 
					
						
							
								
									
										
										
										
											2021-03-25 02:59:15 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-06-23 13:37:46 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								#### `<generator>.iter(..)`
  
						 
					
						
							
								
									
										
										
										
											2021-06-23 09:05:19 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Iterate over the generator.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```bnf
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< generator > .iter() 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    -> < generator > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-06-23 13:37:46 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								XXX move this to `generator.iter(..)` 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Compatible with [`<array>`'s `.iter()` ](#arrayiter--arrayiter ).
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								`.iter(..)`  also supports a handler function 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```bnf
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< generator > .iter(< handler > ) 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    -> < generator > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< handler > (< elem > , < index > ) 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    -> < elem > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    -> [< elem > , ..]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    -> []
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Note that the iterables returned by `<handler>(..)`  will be expanded, to prevent 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								this wrap them in an array.
							 
						 
					
						
							
								
									
										
										
										
											2021-06-23 09:05:19 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-05-25 18:21:30 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								#### `<generator>.map(..)` / `<generator>.filter(..)` 
  
						 
					
						
							
								
									
										
										
										
											2021-03-25 02:59:15 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Equivalents to `Array` 's `.map(..)` , `.filter(..)`  and `.reduce(..)`  but return 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								generators that yield the handler return values.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-05-18 12:24:31 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								`.map(..)`  here also supports a generator as a handler 
						 
					
						
							
								
									
										
										
										
											2021-05-18 02:07:08 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								```javascript
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								var expand = function*(n){ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    yield* (new Array(n)).fill(n) }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// will create: [1, 2, 2, 3, 3, 3]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								var L = [1,2,3]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    .iter()
							 
						 
					
						
							
								
									
										
										
										
											2021-05-18 12:24:31 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        .map(expand)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        .toArray()
							 
						 
					
						
							
								
									
										
										
										
											2021-05-18 02:07:08 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-05-25 17:21:40 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Throwing `STOP`  form within the handler will stop generation, throwing 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								`STOP(<value>)`  will yield the `<value>`  then stop. 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```javascript
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								var stopAt = function(n){
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    return function(e){
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if(e == n){
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            // stop iteration yielding the value we are stopping at...
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            throw generator.STOP(e) } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return e } }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								var L = [1,2,3,4,5]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    .iter()
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        .map(stopAt(3))
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        .toArray()
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-05-25 18:21:30 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								#### `<generator>.reduce(..)` / `<generator>.greduce(..)`
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-03-25 14:40:51 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								<!-- 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								XXX .reduce(..) can return a non-iterable -- test and document this case...
							 
						 
					
						
							
								
									
										
										
										
											2021-05-06 21:46:17 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    ...compare with Array.prototype.reduce(..)
							 
						 
					
						
							
								
									
										
										
										
											2021-03-25 14:40:51 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								-->
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-03-25 02:59:15 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								#### `<generator>.slice(..)`
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-03-25 14:40:51 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								```bnf
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< generator > .slice() 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< generator > .slice(< from > ) 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< generator > .slice(< from > , < to > ) 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    -> < generator > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-05-07 02:50:08 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Note that this does not support negative indexes as it not possible to know the
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								generator length until it is fully done.
							 
						 
					
						
							
								
									
										
										
										
											2021-04-02 11:25:42 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-05-07 02:50:08 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Otherwise this is similar to `Array` 's `.slice(..)`  but will return a generator 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								instead of an array, for more info see:  
							 
						 
					
						
							
								
									
										
										
										
											2021-03-26 02:12:55 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/slice
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-03-25 14:40:51 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-05-11 19:10:45 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								#### `<generator>.at(..)` / `<generator>.gat(..)`
  
						 
					
						
							
								
									
										
										
										
											2021-03-25 02:59:15 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-03-25 14:40:51 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								```bnf
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< generator > .at(< index > ) 
						 
					
						
							
								
									
										
										
										
											2021-05-11 19:10:45 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    -> < value > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    -> undefined
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< generator > .gat(< index > ) 
						 
					
						
							
								
									
										
										
										
											2021-03-25 14:40:51 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    -> < generator > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
									
										
										
										
											2021-05-11 19:10:45 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								<!--  XXX  -->  
						 
					
						
							
								
									
										
										
										
											2021-03-25 14:40:51 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-03-25 02:59:15 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								#### `<generator>.flat(..)`
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-03-25 14:40:51 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								```bnf
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< generator > .flat() 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< generator > .flat(< depth > ) 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    -> < generator > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-03-26 02:12:55 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Equivalent to `Array` 's `.flat(..)`  but will return a generator instead of an 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								array, for more info see:  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/flat
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-03-25 14:40:51 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-05-13 15:59:33 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								#### `<generator>.shift()` / `<generator>.pop()` / `<generator>.gshift()` / `<generator>.gpop()`
  
						 
					
						
							
								
									
										
										
										
											2021-03-25 02:59:15 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-03-26 02:12:55 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Return the first/last item in generator.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```bnf
							 
						 
					
						
							
								
									
										
										
										
											2021-05-13 15:59:33 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								< generator > .shift() 
						 
					
						
							
								
									
										
										
										
											2021-03-26 02:12:55 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								< generator > .pop() 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    -> < value > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    -> undefined
							 
						 
					
						
							
								
									
										
										
										
											2021-05-13 15:59:33 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
									
										
										
										
											2021-03-26 02:12:55 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-05-13 15:59:33 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Return a `<generator>`  that will yield the first/last item in the generator.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```bnf
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< generator > .gshift() 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< generator > .gpop() 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    -> < generator > 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-26 02:12:55 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Note that there are no equivalents to `.push(..)`  and `.unshift(..)`  as they 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								would require breaking item processing order.
							 
						 
					
						
							
								
									
										
										
										
											2021-03-25 02:59:15 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-05-13 15:59:33 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Note that `.shift()` /`.gshift()`  will yield the item the generator is at at 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								time of call, this may not be the _first_  item if the generator is partially 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								depleted.
							 
						 
					
						
							
								
									
										
										
										
											2021-03-25 02:59:15 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-06-26 10:51:49 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								#### `<generator>.unshift(..)` / `<generator>.push(..)`
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Add a value to the generator sequence at start/end.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```bnf
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< generator > .unshift(< value > ) 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< generator > .push(< value > ) 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    -> < generator > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-02-23 23:55:27 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Value added by `.unshift(..)`  will be yielded by `<generator>`  "first", i.e. on 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								_next_ call to `.next()` , regardless of the current generator state.
							 
						 
					
						
							
								
									
										
										
										
											2021-06-26 10:51:49 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-10 03:04:04 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-27 14:50:59 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								#### `<generator>.join(..)`
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								XXX
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-06-21 13:41:06 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								#### `<generator>.then(..)` / `<generator>.catch(..)` / `<generator>.finally(..)`
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Return a promise and resolve it with the generator value.
							 
						 
					
						
							
								
									
										
										
										
											2020-11-10 03:04:04 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-03-25 14:40:51 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								```bnf
							 
						 
					
						
							
								
									
										
										
										
											2022-06-21 13:41:06 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								< generator > .then() 
						 
					
						
							
								
									
										
										
										
											2021-03-25 14:40:51 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    -> < promise > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-06-21 13:41:06 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Adding handlers to the promise
							 
						 
					
						
							
								
									
										
										
										
											2020-11-10 03:04:04 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-03-25 14:40:51 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								```bnf
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< generator > .then(< resolve > , < reject > ) 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    -> < promise > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-06-21 13:41:06 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								< generator > .then(< resolve > ) 
						 
					
						
							
								
									
										
										
										
											2021-03-25 14:40:51 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    -> < promise > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< generator > .finally(< handler > ) 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    -> < promise > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
									
										
										
										
											2022-06-21 13:41:06 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Note that this will deplete the generator.
							 
						 
					
						
							
								
									
										
										
										
											2021-03-25 14:40:51 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-03-26 02:12:55 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								These are the same as equivalent `Promise`  methods, for more info see:  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-03-25 14:40:51 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-10 03:04:04 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								#### `<generator>.toArray()`
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-03-26 02:12:55 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Unwind a generator into an array
							 
						 
					
						
							
								
									
										
										
										
											2021-03-25 14:40:51 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								```bnf
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< generator > .toArray() 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    -> < array > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-03-26 02:12:55 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								This is equivalent to `[...<generator>]`  but more suited for the concatenative style.
							 
						 
					
						
							
								
									
										
										
										
											2021-03-25 14:40:51 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-10 03:04:04 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-06-01 01:12:51 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								### Treating iterators the same as generators
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Most _iterator_  methods of `Array` , `Set`  and `Map`  are extended with the same
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								API supported by the [`<generator>` ](#generator-instance-iteration ), so 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								effectively most built-in iterator methods can be transparently treated as 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								generators.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```javascript
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// this will generate: [1, 4, 9]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								var L = [ ...[1, 2, 3]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    // Note that this is implemented as an iterator in JS and not a generator...
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    .values()
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    .map(function(e){
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return e * e }) ]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-18 06:59:56 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								### Generator constructor iteration
  
						 
					
						
							
								
									
										
										
										
											2020-11-10 03:04:04 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-03-26 02:12:55 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								This API is essentially the same as [generator iteration ](#generator-instance-iteration ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-28 15:21:41 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								with some minor omissions, but will return a reusable generator _pipeline_  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								instead of a generator.
							 
						 
					
						
							
								
									
										
										
										
											2021-03-26 02:12:55 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-10 03:04:04 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								```javascript
							 
						 
					
						
							
								
									
										
										
										
											2020-11-10 03:25:00 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								var sumOdds = generator.iter
							 
						 
					
						
							
								
									
										
										
										
											2020-11-10 03:04:04 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    .filter(function(e){
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return e % 2 == 1 })
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    .reduce(function(r, e){ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return r + e }, 0)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    .pop()
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-03-28 15:21:41 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								// sumOdds(..) is essentially a function that can be reused...
							 
						 
					
						
							
								
									
										
										
										
											2020-11-10 03:25:00 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								console.log(sumOdds([1, 2, 3])) // -> 4
							 
						 
					
						
							
								
									
										
										
										
											2020-11-10 03:04:04 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								console.log(sumOdds([1, 2, 3, 4, 5, 6, 7])) // -> 16
							 
						 
					
						
							
								
									
										
										
										
											2020-11-10 03:25:00 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
									
										
										
										
											2020-11-10 03:04:04 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-10 03:25:00 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								The above code is the same in function to:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```javascript
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								var sumOdds = function(lst){
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    return generator.iter(lst)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        .filter(function(e){
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            return e % 2 == 1 })
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        .reduce(function(r, e){ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            return r + e }, 0)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        .pop() }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								console.log(sumOdds([1, 2, 3])) // -> 4
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								console.log(sumOdds([1, 2, 3, 4, 5, 6, 7])) // -> 16
							 
						 
					
						
							
								
									
										
										
										
											2020-11-10 03:04:04 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-05-11 19:10:45 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								<!--  XXX explain this as a language  -->  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								`<Generator>`  methods fall into two categories: 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								-  `<constructor>`    
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  create a new chained `<Generator>`  object that when called will return 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  a `<generator>` 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								-  `<finalizer>`    
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  create a chained _function_  that when called will return a `<value>` /`undefined` 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```bnf
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< Generator > .< constructor > (..) 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    -> < Generator > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< Generator > .< finalizer > (..) 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    -> < func > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< Generator > (< iterable > ) 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    -> < generator > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< func > (< iterable > ) 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    -> < value > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    -> undefined
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-03-28 15:21:41 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								<!-- 
  
						 
					
						
							
								
									
										
										
										
											2021-05-11 19:10:45 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								XXX list the differences...
							 
						 
					
						
							
								
									
										
										
										
											2021-03-28 15:21:41 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								-->
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-06-23 09:05:19 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								#### `<Generator>.iter(..)`
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								This is a shorthand to [`iter(..)` ](#generatoriter ).
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								This is here mainly for compatibility with 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								[`Array`'s `.iter(..)` ](#arrayiter--arrayiter ).
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-05-11 19:10:45 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								#### `<Generator>.at(..)` / `<Generator>.gat(..)`
  
						 
					
						
							
								
									
										
										
										
											2020-11-10 03:25:00 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-05-10 23:36:32 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								```bnf
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< Generator > .at(< index > ) 
						 
					
						
							
								
									
										
										
										
											2021-05-11 19:10:45 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    -> < func > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< Generator > .gat(< index > ) 
						 
					
						
							
								
									
										
										
										
											2021-05-10 23:36:32 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    -> < Generator > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-05-13 15:59:33 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Equivalents to [`<generator>`'s `.at(..)`/`.gat(..)` ](#generatorat--generatorgat ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								but returning a reusable `<func>` /`<Generator>` .
							 
						 
					
						
							
								
									
										
										
										
											2021-04-02 11:25:42 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-05-11 19:10:45 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								#### `<Generator>.shift()` / `<Generator>.pop()` / `<Generator>.gshift()` / `<Generator>.gpop()`
  
						 
					
						
							
								
									
										
										
										
											2020-11-10 03:04:04 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-05-10 23:36:32 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								```bnf
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< Generator > .shift() 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< Generator > .pop() 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    -> < func > 
							 
						 
					
						
							
								
									
										
										
										
											2021-05-11 19:10:45 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< Generator > .gshift() 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< Generator > .gpop() 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    -> < Generator > 
							 
						 
					
						
							
								
									
										
										
										
											2021-05-10 23:36:32 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-05-11 19:10:45 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Note that `.shift()` /`.gshift()`  will get the element the generator is at 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								currently which may not be the first element in the sequence.
							 
						 
					
						
							
								
									
										
										
										
											2021-05-10 23:36:32 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-05-13 15:59:33 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Equivalents to [`<generator>`'s `.shift(..)`/`.pop(..)`/.. ](#generatorshift--generatorpop--generatorgshift--generatorgpop ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								but returning a reusable `<func>` /`<Generator>` .
							 
						 
					
						
							
								
									
										
										
										
											2021-04-02 11:25:42 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-02-23 23:55:27 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-06-26 10:51:49 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								#### `<generator>.unshift(..)` / `<generator>.push(..)`
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```bnf
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< Generator > .unshift(< value > ) 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< Generator > .push(< value > ) 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    -> < Generator > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Equivalents to [`<generator>`'s `.unshift(..)`/`.push(..)` ](#generatorunshift--generatorpush ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								but returning a reusable `<Generator>` .
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-04-02 11:25:42 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-03-24 18:57:02 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								#### `<Generator>.slice(..)`
  
						 
					
						
							
								
									
										
										
										
											2020-11-10 03:04:04 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-05-11 19:10:45 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								```bnf
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< Generator > .slice(< from > ) 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< Generator > .slice(< from > , < to > ) 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    -> < Generator > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-05-13 15:59:33 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Unlike `Array` 's `.slice(..)`  this does not support negative indexes.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Equivalent to [`<generator>`'s `.slice(..)` ](#generatorslice ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								but returning a reusable `<Generator>` .
							 
						 
					
						
							
								
									
										
										
										
											2020-11-10 03:04:04 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-05-09 02:28:06 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-03-24 18:57:02 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								#### `<Generator>.map(..)` / `<Generator>.filter(..)` / `<Generator>.reduce(..)` / `<Generator>.flat()`
  
						 
					
						
							
								
									
										
										
										
											2020-11-10 03:04:04 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-05-18 02:07:08 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Counterparts to `<generator>` 's 
							 
						 
					
						
							
								
									
										
										
										
											2021-05-25 18:21:30 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								[`.map(..)`, `.filter(..)` ](#generatormap--generatorfilter ), [`.reduce(..)`/`.greduce(..)` ](#generatorreduce--generatorgreduce ) and 
							 
						 
					
						
							
								
									
										
										
										
											2021-05-18 02:07:08 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								[`.flat(..)` ](#generatorflat ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								but return a `<Generator>` .
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-04-02 11:25:42 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								<!--  XXX  -->  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-03-24 18:57:02 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								#### `<Generator>.toArray()`
  
						 
					
						
							
								
									
										
										
										
											2020-11-10 03:04:04 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-05-16 16:58:21 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Return a function that will return a `<generator>`  output as an `Array` .
							 
						 
					
						
							
								
									
										
										
										
											2021-05-14 22:49:31 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								```bnf
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< Generator > .toArray() 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    -> < function > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
									
										
										
										
											2021-04-02 11:25:42 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-27 14:50:59 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								#### `<Generator>.join(..)`
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								XXX
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-04-02 11:25:42 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-03-24 18:57:02 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								#### `<Generator>.then(..)` / `<Generator>.catch(..)` / `<Generator>.finally(..)`
  
						 
					
						
							
								
									
										
										
										
											2020-11-10 03:04:04 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-04-02 11:25:42 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								<!--  XXX  -->  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-10 03:04:04 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-05-25 17:21:40 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								### Generator combinators
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								<!--  XXX  -->  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								#### `<Generator>.chain(..)` / `<generator>.chain(..)`
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```bnf
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< Generator > .chain(< Generator > , ..) 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    -> < Generator > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< generator > .chain(< Generator > , ..) 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    -> < generator > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								<!--  XXX  -->  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```javascript
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// double each element...
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								var x2 = generator.iter
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    .map(function(e){ return e * 2 })
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								generator.range(0, 100).chain(x2)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								#### `<Generator>.concat(..)` / `<generator>.concat(..)` 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Concatenate the results from generators
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```bnf
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< Generator > .concat(< Generator > , ..) 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    -> < Generator > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< generator > .concat(< generator > , ..) 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    -> < generator > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								<!--  XXX Example  -->  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								<!--  XXX
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								#### generator.zip(..) / `<Generator>.zip(..)` / `<generator>.zip(..)` 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								-->
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								<!--  XXX
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								#### `<Generator>.tee(..)` / `<generator>.tee(..)` 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								-->
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								### Generator library
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								#### `generator.range(..)`
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Create a generator yielding a range of numbers
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```bnf
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								range()
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								range(< to > )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								range(< from > , < to > )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								range(< from > , < to > , < step > )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    -> < generator > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								<!--  XXX examples...  -->  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								#### `generator.repeat(..)`
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Create a generator repeatedly yielding `<value>` 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```bnf
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								repeat()
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								repeat(< value > )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								repeat(< value > , < stop > )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    -> < generator > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< stop > (< value > ) 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    -> < bool > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								If no value is given `true`  is yielded by default.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								`<stop>`  if given will be called with each `<value>`  before it is yielded and  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								if it returns `false`  the iteration is stopped.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								<!--  XXX examples...  -->  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								#### `generator.produce(..)`
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Create a generator calling a function to produce yielded values
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```bnf
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								produce()
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								produce(< func > )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    -> < generator > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< func > () 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    -> < value > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								`<func>(..)`  can `throw`  `STOP`  or `STOP(<value>)`  to stop production at any time. 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								<!--  XXX examples...  -->  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								### Generator helpers
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								#### `generator.stoppable(..)`
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Wrap function/generator adding support for stopping mid-iteration by throwing `STOP` .
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```bnf
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								stoppable(< generator > )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    -> < generator > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								<!--  XXX example?  -->  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-06-17 12:01:04 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								## Async generator extensions
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								XXX EXPERIMENTAL
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-06-22 10:26:04 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								#### `generator.AsyncGenerator`
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-06-21 13:49:50 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								#### `<async-generator>.then(..)` / `<async-generator>.catch(..)` / `<async-generator>.finally(..)`
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								#### `<async-generator>.iter(..)`
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								#### `<async-generator>.map(..)` / `<async-generator>.filter(..)` / `<async-generator>.reduce(..)`
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								#### `<async-generator>.chain(..)`
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								#### `<async-generator>.flat(..)`
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								#### `<async-generator>.concat(..)`
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								#### `<async-generator>.push(..)` / `<async-generator>.unshift(..)`
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-05-25 17:21:40 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-10-07 03:53:10 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								## Containers
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-10-07 07:33:58 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								```javascript
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								var containers = require('ig-types').containers
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								or, to only import containers:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```javascript
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								var containers = require('ig-types/containers')
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
									
										
										
										
											2020-10-07 03:53:10 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-05-13 15:59:33 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Note that this will also import [`ig-types/Map` ](#map ).
							 
						 
					
						
							
								
									
										
										
										
											2020-10-07 16:46:59 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-10-07 07:33:58 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								### `containers.UniqueKeyMap()` (`Map`)
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								`UniqueKeyMap`  implements a key-value container (i.e. `Map` ) that supports 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								and maintains _duplicate_  keys by appending an index to them.  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								The original keys are stored internally thus the renaming mechanics are 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								stable.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								`UniqueKeyMap`  extends the `Map`  constructor, so all the usual `Map`   
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								methods and properties apply here.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								To construct an instance:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```javascript
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								var x = new UniqueKeyMap()
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								or:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```javascript
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// new is optional...
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								var y = UniqueKeyMap()
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								`UniqueKeyMap`  supports the same initialization signature as `Map`  but  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								treats repeating keys differently.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```javascript
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								var z = UniqueKeyMap([['a', 1], ['a', 2], ['b', 1]])
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								The second `"a"`  item will automatically get re-keyed as `"a (1)"` :
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```javascript
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								console.log([...z.keys()]) // -> ['a', 'a (1)', 'b']
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Note that `.set(..)`  will never rewrite an element:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```javascript
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								z.set('a', 3)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								console.log([...z.keys()]) // -> ['a', 'a (1)', 'b', 'a (2)']
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								z.get('a') // -> 1
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								z.get('a (1)') // -> 2
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								To get the generated key:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```javascript
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								var k = z.set('a', 4, true)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								console.log(k) // -> 'a (3)'
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								To explicitly rewrite an item:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```javascript
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								z.reset('a (1)', 4)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								z.get('a (1)') // -> 4
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								And we can _rename_  items, i.e. change their key:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```javascript
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								z.rename('a (2)', 'c')
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								console.log([...z.keys()]) // -> ['a', 'a (1)', 'b', 'a (3)', 'c']
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
									
										
										
										
											2020-10-07 03:53:10 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								For more info on `Map`  see:  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-10-07 07:33:58 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-10-07 14:48:47 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								#### `<unique-key-map>.set(..)`
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-12-08 01:53:40 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								```bnf
							 
						 
					
						
							
								
									
										
										
										
											2020-10-07 14:48:47 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								< unique-key-map > .reset(< key > , < item > ) 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    -> < unique-key-map > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< unique-key-map > .reset(< key > , < item > , true) 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    -> < new-key > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Add an `<item>`  to `<unique-key-map>` .
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								If `<key>`  already exists then add an index to it to make it unique.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Key updating is done via [`<unique-key-map>.__key_pattern__` ](#unique-key-map__key_pattern__ ).
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-10-07 03:53:10 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								#### `<unique-key-map>.reset(..)`
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-12-08 01:53:40 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								```bnf
							 
						 
					
						
							
								
									
										
										
										
											2020-10-07 14:48:47 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								< unique-key-map > .reset(< key > , < item > ) 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    -> < unique-key-map > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Explicitly write an `<item>`  under `<key>`  as-is, this is like `Map` 's `.set(..)` .
							 
						 
					
						
							
								
									
										
										
										
											2020-10-07 03:53:10 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-05-09 02:28:06 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-10-07 03:53:10 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								#### `<unique-key-map>.rename(..)`
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-12-08 01:53:40 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								```bnf
							 
						 
					
						
							
								
									
										
										
										
											2020-10-07 15:09:36 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								< unique-key-map > .rename(< from-key > , < to-key > ) 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    -> < unique-key-map > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< unique-key-map > .rename(< from-key > , < to-key > , true) 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    -> < new-key > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Rename item key from `<from-key>`  to `<to-key>` .
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Same mechanics apply as for [`.set(..)` ](#unique-key-mapset ) for key uniqueness.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Note, if [`.__unordered_rename__` ](#unique-key-map__unordered_rename__ ) is 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								`false`  (default) this calls [`.orderedRename(..)` ](#unique-key-maporderedrename )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								otherwise [`.unorderedRename(..)` ](#unique-key-mapunorderedrename ) is called.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								#### `<unique-key-map>.orderedRename(..)`
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-04-02 11:25:42 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								<!--  XXX  -->  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-10-07 14:48:47 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								#### `<unique-key-map>.unorderedRename(..)`
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-04-02 11:25:42 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								<!--  XXX  -->  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-10-07 03:53:10 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								#### `<unique-key-map>.keysOf(..)`
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-04-02 11:25:42 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								<!--  XXX  -->  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-10-07 14:48:47 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								#### `<unique-key-map>.originalKey(..)`
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-04-02 11:25:42 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								<!--  XXX  -->  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-10-07 14:48:47 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								#### `<unique-key-map>.uniqueKey(..)`
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-04-02 11:25:42 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								<!--  XXX  -->  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-10-07 07:33:58 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								#### `<unique-key-map>.__key_pattern__`
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-04-02 11:25:42 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								<!--  XXX  -->  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-10-07 15:09:36 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								#### `<unique-key-map>.__unordered_rename__`
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-04-02 11:25:42 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								<!--  XXX  -->  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-10-07 07:33:58 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-15 05:13:35 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								## Event
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-18 06:09:43 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								```javascript
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								var event = require('ig-types/event')
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-15 05:13:35 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								### `event.Eventfull(..)`
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-04-02 11:25:42 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								<!--  XXX  -->  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-15 05:13:35 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								### `event.Event(..)`
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-04-02 11:25:42 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								<!--  XXX  -->  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-16 02:38:19 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								### `event.TRIGGER`
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-04-02 11:25:42 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								<!--  XXX  -->  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-16 02:38:19 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Special value when passed to an event method as first argument will force it 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								to trigger event if the first argument was a function.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-15 05:13:35 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								### `event.EventHandlerMixin`
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-04-02 11:25:42 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								<!--  XXX  -->  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-15 05:13:35 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								#### `<obj>.on(..)`
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-04-02 11:25:42 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								<!--  XXX  -->  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-15 05:13:35 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								#### `<obj>.one(..)`
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-04-02 11:25:42 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								<!--  XXX  -->  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-15 05:13:35 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								#### `<obj>.off(..)`
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-04-02 11:25:42 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								<!--  XXX  -->  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-15 05:13:35 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								#### `<obj>.trigger(..)`
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-04-02 11:25:42 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								<!--  XXX  -->  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-15 05:13:35 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								### `event.EventDocMixin`
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-04-02 11:25:42 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								<!--  XXX  -->  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-15 05:13:35 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								#### `<obj>.eventfull`
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-04-02 11:25:42 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								<!--  XXX  -->  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-15 05:13:35 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								#### `<obj>.events`
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-04-02 11:25:42 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								<!--  XXX  -->  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-15 05:13:35 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								### `event.EventMixin`
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-28 03:47:31 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Combines [`event.EventHandlerMixin` ](#eventeventhandlermixin ) and 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								[`event.EventDocMixin` ](#eventeventdocmixin ).
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-07 03:19:52 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								## Runner
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-18 06:09:43 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								```javascript
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								var runner = require('ig-types/runner')
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-28 03:47:31 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								### Micro task queue
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-04-02 11:25:42 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								<!--  XXX  -->  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-28 03:47:31 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								This includes [`event.EventMixin` ](#eventeventmixin ).
							 
						 
					
						
							
								
									
										
										
										
											2020-11-18 06:09:43 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-05-26 11:57:21 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								#### `runner.STOP`
  
						 
					
						
							
								
									
										
										
										
											2020-12-17 18:55:28 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-04-02 11:25:42 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								<!--  XXX  -->  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-05-26 11:57:21 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								#### `runner.SKIP`
  
						 
					
						
							
								
									
										
										
										
											2020-12-17 18:55:28 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-04-02 11:25:42 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								<!--  XXX  -->  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-12-17 18:55:28 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-12-08 01:53:40 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								#### `Queue(..)` / `Queue.runTasks(..)`
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-04-02 11:25:42 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								<!--  XXX  -->  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-12-08 01:53:40 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								#### `Queue.handle(..)`
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Create a handler queue object.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```bnf
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Queue.handle(< func > , ...< data > )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Queue.handle(< options > , < func > , ...< data > )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    -> < queue > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								A handler queue is a queue that has a single handler function (`.handle(..)` ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								that handles the queue data.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								This is a shorthand for:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```javascript
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								var handler_queue = Queue({
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        handler: function(item){ .. }, 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        .. 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    }, 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    .. )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
									
										
										
										
											2020-11-07 03:19:52 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-12-17 18:55:28 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								<!--  XXX settings...  -->  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-07 03:19:52 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								#### `<queue>.state`
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-04-02 11:25:42 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								<!--  XXX  -->  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-12-08 01:53:40 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-07 03:19:52 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								#### `<queue>.start(..)`
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-04-02 11:25:42 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								<!--  XXX  -->  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-12-08 01:53:40 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								#### `<queue>.stop(..)`
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-04-02 11:25:42 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								<!--  XXX  -->  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-07 03:19:52 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-12-08 01:53:40 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								#### `<queue>.runTask(..)`
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-04-02 11:25:42 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								<!--  XXX  -->  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-12-08 01:53:40 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								#### `<queue>.tasksAdded(..)` (event)
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-04-02 11:25:42 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								<!--  XXX  -->  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-12-08 01:53:40 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								#### `<queue>.taskStarting(..)` (event)
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-04-02 11:25:42 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								<!--  XXX  -->  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-12-08 01:53:40 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								#### `<queue>.taskFailed(..)` (event)
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-04-02 11:25:42 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								<!--  XXX  -->  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-28 03:47:31 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								#### `<queue>.taskCompleted(..)` (event)
  
						 
					
						
							
								
									
										
										
										
											2020-11-07 03:19:52 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-28 03:47:31 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Event, triggered when a task is completed passing in its result.
							 
						 
					
						
							
								
									
										
										
										
											2020-11-07 03:19:52 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-04-02 11:25:42 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								<!--  XXX  -->  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-07 03:19:52 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-12-08 01:53:40 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								#### `<queue>.queueEmpty(..)` (event)
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-04-02 11:25:42 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								<!--  XXX  -->  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-12-08 01:53:40 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-12-17 18:55:28 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								#### `<queue>.prioritize(..)`
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-04-02 11:25:42 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								<!--  XXX  -->  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-12-17 18:55:28 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								#### `<queue>.delay(..)`
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-04-02 11:25:42 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								<!--  XXX  -->  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-12-17 18:55:28 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								#### `<queue>.add(..)`
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-04-02 11:25:42 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								<!--  XXX  -->  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-12-17 18:55:28 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								#### `<queue>.clear(..)`
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-04-02 11:25:42 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								<!--  XXX  -->  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-12-17 18:55:28 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								#### `FinalizableQueue(..)` / `FinalizableQueue.runTasks(..)` (Queue)
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-05-09 02:28:06 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								This is similar to `Queue(..)`  but adds two terminal states (`"done"`  and 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								`"aborted"` ) and a `promise` -mapping. 
						 
					
						
							
								
									
										
										
										
											2020-12-17 18:55:28 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```bnf
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								FinalizableQueue.handle(< func > , ...< data > )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								FinalizableQueue.handle(< options > , < func > , ...< data > )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    -> < finalizable-queue > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								When a `<finalizable-queue>`  reaches a terminal state it is frozen.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								#### `<finalizable-queue>.done(..)` (event/method)
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-04-02 11:25:42 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								<!--  XXX  -->  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-12-17 18:55:28 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								#### `<finalizable-queue>.abort(..)` (event/method)
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-04-02 11:25:42 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								<!--  XXX  -->  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-12-17 18:55:28 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								#### `<finalizable-queue>.promise(..)`
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-04-02 11:25:42 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								<!--  XXX  -->  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-12-17 18:55:28 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								#### `<finalizable-queue>.then(..)`
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-04-02 11:25:42 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								<!--  XXX  -->  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-12-17 18:55:28 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								#### `<finalizable-queue>.catch(..)`
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-04-02 11:25:42 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								<!--  XXX  -->  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-12-17 18:55:28 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-12-08 01:53:40 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-28 03:47:31 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								### Large task management
  
						 
					
						
							
								
									
										
										
										
											2020-11-07 03:19:52 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-04-02 11:25:42 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								<!--  XXX  -->  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-28 03:47:31 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								#### `runner.TaskManager(..)`
  
						 
					
						
							
								
									
										
										
										
											2020-11-07 03:19:52 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-04-02 11:25:42 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								<!--  XXX  -->  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-07 03:19:52 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-28 03:47:31 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								This includes [`event.EventMixin` ](#eventeventmixin ).
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								#### `<task-manager>.Task(..)`
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-04-02 11:25:42 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								<!--  XXX  -->  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-28 03:47:31 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								#### `<task-manager>.sync_start`
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-04-02 11:25:42 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								<!--  XXX  -->  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-28 03:47:31 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								#### `<task-manager>.record_times`
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-04-02 11:25:42 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								<!--  XXX  -->  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-28 03:47:31 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								#### `<task-manager>.titled(..)`
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-04-02 11:25:42 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								<!--  XXX  -->  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-28 03:47:31 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								#### `<task-manager>.send(..)`
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-04-02 11:25:42 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								<!--  XXX  -->  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-28 03:47:31 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								#### `<task-manager>.stop(..)`
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-04-02 11:25:42 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								<!--  XXX  -->  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-28 03:47:31 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								#### `<task-manager>.done(..)` (event)
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-04-02 11:25:42 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								<!--  XXX  -->  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-28 03:47:31 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								#### `<task-manager>.error(..)` (event)
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-04-02 11:25:42 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								<!--  XXX  -->  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-28 03:47:31 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								#### `<task-manager>.tasksDone(..)` (event)
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-04-02 11:25:42 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								<!--  XXX  -->  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-28 03:47:31 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								#### `runner.TaskTicket(..)`
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-04-02 11:25:42 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								<!--  XXX  -->  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-28 03:47:31 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								#### `runner.TaskMixin(..)`
  
						 
					
						
							
								
									
										
										
										
											2020-11-07 03:19:52 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-04-02 11:25:42 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								<!--  XXX  -->  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-07 03:19:52 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-10-07 07:33:58 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								## License
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								[BSD 3-Clause License ](./LICENSE )
							 
						 
					
						
							
								
									
										
										
										
											2020-10-07 03:53:10 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-10-07 07:33:58 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Copyright (c) 2020, Alex A. Naanou,  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								All rights reserved.
							 
						 
					
						
							
								
									
										
										
										
											2020-10-07 03:53:10 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-04-30 09:58:49 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								<!--  vim:set ts=4 sw=4 spell :  -->