'use strict';
const { AigleWhilst, WhilstTester } = require('./whilst');
class UntilTester extends WhilstTester {
constructor(tester) {
super(tester);
}
_callResolve(value) {
if (value) {
this._proxy._promise._resolve(this._value);
} else {
this._proxy._next(this._value);
}
}
}
module.exports = { until, UntilTester };
/**
* @param {*} [value]
* @param {Function} tester
* @param {Function} iterator
*/
function until(value, tester, iterator) {
if (typeof iterator !== 'function') {
iterator = tester;
tester = value;
value = undefined;
}
return new AigleWhilst(new UntilTester(tester), iterator)._iterate(value);
}