function concat(queries, capSQL) {
    if (!Array.isArray(queries)) {
        throw new TypeError('Parameter \'queries\' must be an array.');
    }
    const fmOptions = {capSQL};
    const all = queries.map((q, index) => {
        if (typeof q === 'string') {
            // a simple query string without parameters:
            return clean(q);
        }
        if (q && typeof q === 'object') {
            if (q instanceof QueryFile) {
                // QueryFile object:
                return clean(q[npm.formatting.as.ctf.toPostgres]());
            }
            if ('query' in q) {
                // object {query, values, options}:
                let opt = q.options && typeof q.options === 'object' ? q.options : {};
                opt = opt.capSQL === undefined ? Object.assign(opt, fmOptions) : opt;
                return clean(npm.formatting.as.format(q.query, q.values, opt));
            }
        }
        throw new Error(`Invalid query element at index ${index}.`);
    });

    return all.filter(q => q).join(';');
}
@method helpers.concat
@description
Formats and concatenates multiple queries into a single query string.

Before joining the queries, the method does the following:
 - Formats each query, if `values` are provided;
 - Removes all leading and trailing spaces, tabs and semi-colons;
 - Automatically skips all empty queries.

@param {array<string|helpers.QueryFormat|QueryFile>} queries
Array of mixed-type elements:
- a simple query string, to be used as is
- a {@link helpers.QueryFormat QueryFormat}-like object = `{query, [values], [options]}`
- a {@link QueryFile} object

@returns {string}
Concatenated string with all queries.

@example

const pgp = require('pg-promise')();

const qf1 = new pgp.QueryFile('./query1.sql', {minify: true});
const qf2 = new pgp.QueryFile('./query2.sql', {minify: true});

const query = pgp.helpers.concat([
    {query: 'INSERT INTO Users(name, age) VALUES($1, $2)', values: ['John', 23]}, // QueryFormat-like object
    {query: qf1, values: [1, 'Name']}, // QueryFile with formatting parameters
    'SELECT count(*) FROM Users', // a simple-string query,
    qf2 // direct QueryFile object
]);

// query = concatenated string with all the queries