mirror of
https://github.com/flynx/stoppable.js.git
synced 2025-10-29 02:40:08 +00:00
notes...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
7d9b494305
commit
356df9c1d5
@ -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,
|
||||||
} }
|
} }
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user