
function QueryEngine() {
}
QueryEngine.prototype.byIsbn = function() {};

var engines = [];

module.exports = (function() {
    var engines = [];

    var searchByISBN = async function(isbn) {
        var all = await Promise.all(engines.map(i => i.byIsbn(isbn)));
        var result = [];
        all.forEach(i => i.forEach(j => result.push(j)));
        return result;
    };

    return {
        ByISBN: searchByISBN,
        QueryEngine: QueryEngine,
        newBook: function(title, author, identifier) {
            return {
                title: title,
                author: author,
                identifier: identifier
            };
        },
        register: function(engine) {
            engines.push(engine);
        }
    };
})();

