summaryrefslogtreecommitdiffstats
path: root/lib/api/decodeGlobal.js
blob: 118afb29b6f50f0dc6a0e8ee602d57ba3b60191e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
var decodeConfig = require('./decodeConfig');

/**
    Decode changes from a JS API to a output object.
    Only the configuration can be edited by plugin's hooks

    @param {Output} output
    @param {Object} result: result from API
    @return {Output}
*/
function decodeGlobal(output, result) {
    var book = output.getBook();
    var config = book.getConfig();

    // Update config
    config = decodeConfig(config, result.config);
    book = book.set('config', config);

    return output.set('book', book);
}

module.exports = decodeGlobal;