|
@@ -4,7 +4,12 @@ const {none, flushable} = require('../defs');
|
|
|
|
|
|
|
|
const fold = (f, acc) =>
|
|
const fold = (f, acc) =>
|
|
|
flushable(value => {
|
|
flushable(value => {
|
|
|
- if (value === none) return acc;
|
|
|
|
|
|
|
+ if (value === none) {
|
|
|
|
|
+ // clean up acc
|
|
|
|
|
+ const result = acc;
|
|
|
|
|
+ acc = null;
|
|
|
|
|
+ return result;
|
|
|
|
|
+ }
|
|
|
const result = f(acc, value);
|
|
const result = f(acc, value);
|
|
|
if (result && typeof result.then == 'function') {
|
|
if (result && typeof result.then == 'function') {
|
|
|
return result.then(result => {
|
|
return result.then(result => {
|