src/privates/_flatten.js
function _flatten (array, isDeep, output, idx) {
    for (var i = 0, len = array.length, value, j, vLen; i < len; i++) {
        value = array[i];

        if (!Array.isArray(value)) {
            output[idx++] = value;
        } else if (isDeep) {
            _flatten(value, true, output, idx);
            idx = output.length;
        } else {
            vLen = value.length;
            output.length += vLen;

            for (j = 0; j < vLen; j++) {
                output[idx++] = value[j];
            }
        }
    }

    return output;
}
function _flatten (array, isDeep, output, idx) {
    for (var i = 0, len = array.length, value, j, vLen; i < len; i++) {
        value = array[i];

        if (!Array.isArray(value)) {
            output[idx++] = value;
        } else if (isDeep) {
            _flatten(value, true, output, idx);
            idx = output.length;
        } else {
            vLen = value.length;
            output.length += vLen;

            for (j = 0; j < vLen; j++) {
                output[idx++] = value[j];
            }
        }
    }

    return output;
}
function _flatten ( array , isDeep , output , idx ) { for ( var i = 0 , len = array . length , value , j , vLen ; i < len ; i ++ ) { value = array [ i ] ; if ( ! Array . isArray ( value ) ) { output [ idx ++ ] = value ; } else if ( isDeep ) { _flatten ( value , true , output , idx ) ; idx = output . length ; } else { vLen = value . length ; output . length += vLen ; for ( j = 0 ; j < vLen ; j ++ ) { output [ idx ++ ] = value [ j ] ; } } } return output ; }
Flattens an array.
@private
@param {Array} array - The source array
@param {Boolean} isDeep - Whether to perform a deep flattening or not
@param {Array} output - An array to collect the result
@param {Number} idx - The next index to be filled in the output
@returns {Array} The output array filled with the results
Flattens an array .