diff options
Diffstat (limited to 'src/wrapper.js')
-rw-r--r-- | src/wrapper.js | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/wrapper.js b/src/wrapper.js new file mode 100644 index 0000000..8ab8eac --- /dev/null +++ b/src/wrapper.js @@ -0,0 +1,8 @@ +export const DO = (unit, bind) => f => { + const gen = f() + const next = acc => { + const {done, value} = gen.next(acc) + return done ? unit(value) : bind(value)(next) + } + return next() +} |