Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2022-07-07 11:29:21 +03:00
parent 7d9b494305
commit 356df9c1d5

View File

@ -16,8 +16,8 @@
//--------------------------------------------------------------------- //---------------------------------------------------------------------
// helpers...
// need to expose some types that JS hides from us...
var AsyncFunction = var AsyncFunction =
(async function(){}).constructor (async function(){}).constructor
@ -45,6 +45,7 @@ var AsyncGenerator =
// //
// The client callable can be one of: // The client callable can be one of:
// - function // - function
// - async function
// - generator // - generator
// - async generator // - async generator
// //
@ -71,6 +72,7 @@ function(func){
return Object.assign( return Object.assign(
// NOTE: the below implementations are almost the same, the main // NOTE: the below implementations are almost the same, the main
// differences being the respective generator/async mechanics... // differences being the respective generator/async mechanics...
// generator...
func instanceof Generator ? func instanceof Generator ?
function*(){ function*(){
try{ try{
@ -88,6 +90,7 @@ function(func){
yield err.value yield err.value
return } return }
throw err } } throw err } }
// async generator...
: func instanceof AsyncGenerator ? : func instanceof AsyncGenerator ?
async function*(){ async function*(){
try{ try{
@ -105,6 +108,7 @@ function(func){
yield err.value yield err.value
return } return }
throw err } } throw err } }
// async function...
: func instanceof AsyncFunction ? : func instanceof AsyncFunction ?
async function(){ async function(){
try{ try{
@ -121,6 +125,7 @@ function(func){
} else if(err instanceof module.STOP){ } else if(err instanceof module.STOP){
return err.value } return err.value }
throw err } } throw err } }
// function...
: function(){ : function(){
try{ try{
var res = func.call(this, ...arguments) var res = func.call(this, ...arguments)
@ -147,6 +152,7 @@ module.STOP =
function(value){ function(value){
return { return {
__proto__: module.STOP.prototype, __proto__: module.STOP.prototype,
doc: 'stop iteration.', doc: 'stop iteration.',
value, value,
} } } }