{"size": 715, "ext": "js", "max_stars_repo_path": "public/assets/lib/jwplayer-master/src/js/api/Setup.js", "max_stars_repo_name": "hoangnhonline/study-2017", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "public/assets/lib/jwplayer-master/src/js/api/Setup.js", "max_issues_repo_name": "hoangnhonline/study-2017", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "public/assets/lib/jwplayer-master/src/js/api/Setup.js", "max_forks_repo_name": "hoangnhonline/study-2017", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 26.4814814815, "max_line_length": 127, "alphanum_fraction": 0.627972028}
import startSetup from 'api/setup-steps';

const SETUP_TIMEOUT_SECONDS = 30;

const Setup = function(_model) {

    let _setupFailureTimeout;

    this.start = function () {
        const setupPromise = startSetup(_model);
        return new Promise((resolve, reject) => {
            _setupFailureTimeout = setTimeout(() => {
                reject(new Error(`Setup Timeout Error: Setup took longer than ${SETUP_TIMEOUT_SECONDS} seconds to complete.`));
            }, SETUP_TIMEOUT_SECONDS * 1000);
            return setupPromise.then(resolve).catch(reject);
        });
    };

    this.destroy = function() {
        clearTimeout(_setupFailureTimeout);
        _model = null;
    };

};

export default Setup;
