{"size": 1195, "ext": "js", "max_stars_repo_path": "client/js/BootstrapStep.js", "max_stars_repo_name": "kipyegonmark/whatsapp-web-reveng", "max_stars_repo_stars_event_min_datetime": "2021-06-03T15:55:36.000Z", "max_stars_repo_stars_event_max_datetime": "2021-06-28T08:42:40.000Z", "max_issues_repo_path": "client/js/BootstrapStep.js", "max_issues_repo_name": "kipyegonmark/whatsapp-web-reveng", "max_issues_repo_issues_event_min_datetime": "2021-01-05T19:57:16.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-13T04:57:54.000Z", "max_forks_repo_path": "client/js/BootstrapStep.js", "max_forks_repo_name": "kipyegonmark/whatsapp-web-reveng", "max_forks_repo_forks_event_min_datetime": "2018-10-11T17:46:21.000Z", "max_forks_repo_forks_event_max_datetime": "2019-02-05T15:05:56.000Z"}
{"max_stars_count": 2, "max_issues_count": 2, "max_forks_count": 2, "avg_line_length": 22.9807692308, "max_line_length": 54, "alphanum_fraction": 0.6284518828}
class BootstrapStep {
	constructor({websocket, texts, actor, request}) {
		this.websocket = websocket;
		this.texts = texts;
		this.actor = actor;
		this.request = request;
	}

	run(timeout) {
		return new Promise((resolve, reject) => {
			if(this.actor != undefined)
				this.actor(this.websocket);

			let promise;
			switch(this.request.type) {
				case "waitForMessage": {
					promise = this.websocket.waitForMessage({
						condition: this.request.condition,
						keepWhenHit: false,
						timeout: timeout
					});
					break;
				}

				case "call": {
					promise = this.websocket.call({
						callArgs: this.request.callArgs,
						ignoreCondition: this.request.ignoreCondition,
						successCondition: this.request.successCondition,
						successActor: this.request.successActor,
						failureActor: this.request.failureActor,
						timeoutCondition: this.request.timeoutCondition,
						timeout: timeout
					});
					break;
				}
			}
			if(promise != undefined) {
				return promise.then((...args) => {
					resolve(...args);
				})
				.catch((...args) => {
					reject(...args);
				});
			}
		});
	}
}

if(typeof window === 'undefined')
	exports.BootstrapStep = BootstrapStep;
