From 1c37869e60d1aaa0c4d0448c362bf77eec6a0603 Mon Sep 17 00:00:00 2001 From: Vitaliy Filippov Date: Tue, 16 Aug 2016 17:31:54 +0300 Subject: [PATCH] support calling gen.run from inside of a running generator --- index.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index c03a547..8ad9e7a 100644 --- a/index.js +++ b/index.js @@ -64,6 +64,7 @@ function callGen(thread, method, arg) return; } var v; + var prev = current; thread._running = true; current = thread; try @@ -86,7 +87,7 @@ function callGen(thread, method, arg) v = { error: e }; } thread._running = false; - current = null; + current = prev; if (v.done || v.error) { // generator finished