@theintern/leadfoot
Version:
Leadfoot. A JavaScript client library that brings cross-platform consistency to the Selenium WebDriver API.
28 lines • 1.2 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
var pollUntil_1 = __importDefault(require("./pollUntil"));
var util_1 = require("../lib/util");
function pollUntilTruthy(poller, argsOrTimeout, timeout, pollInterval) {
var args = [];
if (typeof argsOrTimeout === 'number') {
pollInterval = timeout;
timeout = argsOrTimeout;
}
else if (argsOrTimeout) {
args.push.apply(args, argsOrTimeout);
}
args.unshift(util_1.toExecuteString(poller));
var _poller = /* istanbul ignore next */ function (poller) {
var args = Array.prototype.slice.apply(arguments).slice(1);
var result = new Function(poller).apply(null, args);
// If result is truthy, return it. Otherwise return `undefined`, which
// will cause pollUntil to continue polling.
return result ? result : undefined;
};
return pollUntil_1.default(util_1.toExecuteString(_poller), args, timeout, pollInterval);
}
exports.default = pollUntilTruthy;
//# sourceMappingURL=pollUntilTruthy.js.map