<commit_before>// Requires
var later = require('later');


// Variables
var timer = null;
var last;


// Functions
function startSchedule(number, unit) {
    if(!timer) {
        var interval = later.parse.text('every ' + number + ' ' + unit);
        timer = later.setInterval(updateWallpaper, interval);
    }
}

function pauseSchedule() {
    timer.clear();
}

function updateWallpaper() {
    var id = last;
    var random;

    while(id === last) {
        random = Math.floor(Math.random() * user.scheduled.length);
        id = user.scheduled[random];
    }

    last = id;
    return wallpaper.setWallpaper(id);
}


// Exports
module.exports = {
    startSchedule: function(number, unit) {
        return startSchedule(number, unit);
    },

    pauseSchedule: function() {<commit_msg>Fixed bug when scheduling 0 or 1 images<commit_after>// Requires
var later = require('later');


// Variables
var timer = null;
var last;


// Functions
function startSchedule(number, unit) {
    if(!timer) {
        var interval = later.parse.text('every ' + number + ' ' + unit);
        timer = later.setInterval(updateWallpaper, interval);
    }
}

function pauseSchedule() {
    timer.clear();
}

function updateWallpaper() {
    var id = last;
    var random;

    // If there are no scheduleds images, return
    if(user.scheduled.length === 0){
        return;
    }

    // If there is only one image scheduled, ignore loop
    while(id === last && user.scheduled.length > 1) {
        random = Math.floor(Math.random() * user.scheduled.length);
        id = user.scheduled[random];
    }

    last = id;
    return wallpaper.setWallpaper(id);
}


// Exports
module.exports = {
    startSchedule: function(number, unit) {
        return startSchedule(number, unit);
    },

    pauseSchedule: function() {
{'fraction_non_alphanumeric': 0.1344770337576093, 'fraction_numerical': 0.002213613724405091, 'mean_word_length': 2.7666666666666666, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3462507', 'n_tokens_mistral': 560, 'n_tokens_neox': 536, 'n_words': 138}