mirror of
https://github.com/flynx/types.js.git
synced 2025-12-19 18:01:39 +00:00
found bug, not isolated yet...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
0595479171
commit
db83dd7575
14
Promise.js
14
Promise.js
@ -523,6 +523,20 @@ object.Constructor('IterablePromise', Promise, {
|
||||
// NOTE: if 'types/Array' is imported this will support throwing STOP,
|
||||
// for more info see notes for .__pack(..)
|
||||
// XXX EXPEREMENTAL: STOP...
|
||||
//
|
||||
// XXX BUG:
|
||||
// await Promise.iter(['a', Promise.resolve(222), ['c']])
|
||||
// .map(async e => e)
|
||||
// -> ['a', <promise>, ['c']]
|
||||
// is not the same as:
|
||||
// await Promise.iter(['a', Promise.resolve(222), ['c']])
|
||||
// .map(e => e)
|
||||
// -> ['a', 222, ['c']]
|
||||
// ...and these works as expected:
|
||||
// await Promise.iter(['a', Promise.resolve(222), ['c']], async e => [e])
|
||||
// -> ['a', 222, ['c']]
|
||||
// await Promise.iter(['a', Promise.resolve(222), ['c']], e => [e])
|
||||
// -> ['a', 222, ['c']]
|
||||
__new__: function(_, list, handler){
|
||||
// instance...
|
||||
var promise
|
||||
|
||||
43
generator.js
43
generator.js
@ -66,6 +66,14 @@ module.Generator =
|
||||
(function*(){}).constructor
|
||||
|
||||
|
||||
var AsyncGeneratorPrototype =
|
||||
(async function*(){}).constructor.prototype
|
||||
|
||||
var AsyncGenerator =
|
||||
module.AsyncGenerator =
|
||||
(async function*(){}).constructor
|
||||
|
||||
|
||||
// base iterator prototypes...
|
||||
var ITERATOR_PROTOTYPES = [
|
||||
Array,
|
||||
@ -428,6 +436,41 @@ ITERATOR_PROTOTYPES
|
||||
GeneratorProtoMixin(proto) })
|
||||
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
// XXX EXPERIMENTAL...
|
||||
|
||||
var makeAsyncGenerator = function(name, pre){
|
||||
return function(...args){
|
||||
var that = this
|
||||
return Object.assign(
|
||||
async function*(){
|
||||
var a = pre ?
|
||||
pre.call(this, args, ...arguments)
|
||||
: args
|
||||
for await (var e of that(...arguments)[name](...a)){
|
||||
yield e } },
|
||||
{ toString: function(){
|
||||
return [
|
||||
that.toString(),
|
||||
// XXX need to normalize args better...
|
||||
`.${ name }(${ args.join(', ') })`,
|
||||
].join('\n ') }, }) } }
|
||||
|
||||
var AsyncGeneratorMixin =
|
||||
module.AsyncGeneratorMixin =
|
||||
object.Mixin('AsyncGeneratorMixin', 'soft', {
|
||||
map: makeAsyncGenerator('map'),
|
||||
})
|
||||
|
||||
var AsyncGeneratorProtoMixin =
|
||||
module.AsyncGeneratorProtoMixin =
|
||||
object.Mixin('AsyncGeneratorProtoMixin', 'soft', {
|
||||
})
|
||||
|
||||
//AsyncGeneratorMixin(AsyncGeneratorPrototype)
|
||||
//AsyncGeneratorProtoMixin(AsyncGeneratorPrototype.prototype)
|
||||
|
||||
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
// Generators...
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user