const $arrayRemoveAt = function(array, index) {
    array.splice(index, 1);
};

const $arrayRemoveValue = function(array, item) {
    let index;
    while(array.length > 0 && (index = array.indexOf(item)) >= 0)
        $arrayRemoveAt(array, index);
};

const $arrayRemoveAny = function(array, predicate) {
    let index;
    while(array.length > 0 && (index = array.findIndex(predicate)) >= 0)
        $arrayRemoveAt(array, index);
};

const $arrayShuffle = function(array) {
    if(array.length < 2)
        return;

    for(let i = array.length - 1; i > 0; --i) {
        const j = Math.floor(Math.random() * (i + 1));
        const tmp = array[i];
        array[i] = array[j];
        array[j] = tmp;
    }
};