mirror of
https://github.com/flynx/types.js.git
synced 2025-10-29 02:20:07 +00:00
notes...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
40d08efc5c
commit
90fe7eb818
42
Promise.js
42
Promise.js
@ -80,25 +80,28 @@ object.Constructor('IterablePromise', Promise, {
|
||||
// .sort(..)
|
||||
// XXX should these support STOP???
|
||||
map: function(func){
|
||||
return this.constructor(this.__list, function(e){
|
||||
return [func(e)] }) },
|
||||
filter: function(func){
|
||||
return this.constructor(this.__list, function(e){
|
||||
return func(e) ?
|
||||
[e]
|
||||
: [] }) },
|
||||
reduce: function(func, res){
|
||||
return this.constructor(this.__list,
|
||||
function(e){
|
||||
res = func(res, e)
|
||||
return [] })
|
||||
return [func(e)] }) },
|
||||
filter: function(func){
|
||||
return this.constructor(this.__list,
|
||||
function(e){
|
||||
return func(e) ?
|
||||
[e]
|
||||
: [] }) },
|
||||
reduce: function(func, res){
|
||||
return this.constructor(this.__list,
|
||||
function(e){
|
||||
res = func(res, e)
|
||||
return [] })
|
||||
.then(function(){
|
||||
return res }) },
|
||||
flat: function(depth=1){
|
||||
return this.constructor(this.__list, function(e){
|
||||
return (e && e.flat) ?
|
||||
e.flat(depth)
|
||||
: e }) },
|
||||
return this.constructor(this.__list,
|
||||
function(e){
|
||||
return (e && e.flat) ?
|
||||
e.flat(depth)
|
||||
: e }) },
|
||||
|
||||
|
||||
// XXX do we need:
|
||||
@ -173,7 +176,15 @@ object.Constructor('IterablePromise', Promise, {
|
||||
// XXX if list is an iterator, can we fill this async???
|
||||
// XXX iterator/generator as input:
|
||||
// - do we unwind here or externally?
|
||||
// ...feels like with the generator external unwinding is needed...
|
||||
// ...feels like with the generator external unwinding is
|
||||
// needed...
|
||||
// XXX would be nice to support trowing STOP...
|
||||
// - this is more complicated than simply suing .smap(..) instead
|
||||
// of .map(..) because the list can contain async promises...
|
||||
// ...would need to wrap each .then(..) call in try-catch and
|
||||
// manually handle the stop...
|
||||
// - another issue here is that the stop would happen in order of
|
||||
// execution and not order of elements...
|
||||
__new__: function(_, list, handler){
|
||||
var promise
|
||||
|
||||
@ -197,6 +208,7 @@ object.Constructor('IterablePromise', Promise, {
|
||||
list =
|
||||
// apply the handler...
|
||||
handler ?
|
||||
// XXX can we handle STOP here???
|
||||
list.map(function(block){
|
||||
return (block instanceof Array ?
|
||||
block
|
||||
|
||||
10
README.md
10
README.md
@ -1,6 +1,6 @@
|
||||
# types.js
|
||||
|
||||
A library of JavaScript type extensions, types and type utilities.
|
||||
Library of JavaScript type extensions, types and utilities.
|
||||
|
||||
- [types.js](#typesjs)
|
||||
- [Installation](#installation)
|
||||
@ -128,8 +128,8 @@ A library of JavaScript type extensions, types and type utilities.
|
||||
- [`event.EventMixin`](#eventeventmixin)
|
||||
- [Runner](#runner)
|
||||
- [Micro task queue](#micro-task-queue)
|
||||
- [`STOP`](#stop)
|
||||
- [`SKIP`](#skip)
|
||||
- [`runner.STOP`](#runnerstop)
|
||||
- [`runner.SKIP`](#runnerskip)
|
||||
- [`Queue(..)` / `Queue.runTasks(..)`](#queue--queueruntasks)
|
||||
- [`Queue.handle(..)`](#queuehandle)
|
||||
- [`<queue>.state`](#queuestate)
|
||||
@ -2299,12 +2299,12 @@ var runner = require('ig-types/runner')
|
||||
|
||||
This includes [`event.EventMixin`](#eventeventmixin).
|
||||
|
||||
#### `STOP`
|
||||
#### `runner.STOP`
|
||||
|
||||
<!-- XXX -->
|
||||
|
||||
|
||||
#### `SKIP`
|
||||
#### `runner.SKIP`
|
||||
|
||||
<!-- XXX -->
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user