mirror of
https://github.com/flynx/object.js.git
synced 2025-10-28 18:10:08 +00:00
tweaking stoppable...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
1944b5ceca
commit
ff294074d3
31
object.js
31
object.js
@ -396,8 +396,10 @@ var AsyncGenerator =
|
||||
module.AsyncGenerator =
|
||||
(async function*(){}).constructor
|
||||
|
||||
|
||||
// XXX should we have a generic generator that cand return STOP???
|
||||
|
||||
|
||||
// XXX
|
||||
var stoppable =
|
||||
module.stoppable =
|
||||
@ -409,7 +411,17 @@ function(func){
|
||||
// in sync...
|
||||
function*(){
|
||||
try{
|
||||
/* XXX should we return STOP???
|
||||
yield* func.call(this, ...arguments)
|
||||
/*/
|
||||
for(var res of func.call(this, ...arguments)){
|
||||
if(res === STOP){
|
||||
return }
|
||||
if(res instanceof STOP){
|
||||
yield res.value
|
||||
return }
|
||||
yield res }
|
||||
//*/
|
||||
} catch(err){
|
||||
if(err === STOP){
|
||||
return
|
||||
@ -423,7 +435,17 @@ function(func){
|
||||
// in sync...
|
||||
async function*(){
|
||||
try{
|
||||
/* XXX should we return STOP???
|
||||
yield* func.call(this, ...arguments)
|
||||
/*/
|
||||
for(var res of func.call(this, ...arguments)){
|
||||
if(res === STOP){
|
||||
return }
|
||||
if(res instanceof STOP){
|
||||
yield res.value
|
||||
return }
|
||||
yield res }
|
||||
//*/
|
||||
} catch(err){
|
||||
if(err === STOP){
|
||||
return
|
||||
@ -433,7 +455,16 @@ function(func){
|
||||
throw err } }
|
||||
: function(){
|
||||
try{
|
||||
/* XXX should we return STOP???
|
||||
return func.call(this, ...arguments)
|
||||
/*/
|
||||
var res = func.call(this, ...arguments)
|
||||
if(res === STOP){
|
||||
return }
|
||||
if(res instanceof STOP){
|
||||
return res.value }
|
||||
return res
|
||||
//*/
|
||||
} catch(err){
|
||||
if(err === STOP){
|
||||
return
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user