diff options
Diffstat (limited to 'lib/json')
-rw-r--r-- | lib/json/encodeBookWithPage.js | 12 | ||||
-rw-r--r-- | lib/json/encodeOutput.js | 10 | ||||
-rw-r--r-- | lib/json/encodeOutputWithPage.js | 23 | ||||
-rw-r--r-- | lib/json/index.js | 1 |
4 files changed, 35 insertions, 11 deletions
diff --git a/lib/json/encodeBookWithPage.js b/lib/json/encodeBookWithPage.js index 5600a82..1c5c7a3 100644 --- a/lib/json/encodeBookWithPage.js +++ b/lib/json/encodeBookWithPage.js @@ -3,12 +3,12 @@ var encodePage = require('./encodePage'); var encodeFile = require('./encodeFile'); /** - Return a JSON representation of a book with a specific file - - @param {Book} output - @param {Page} page - @return {Object} -*/ + * Return a JSON representation of a book with a specific file + * + * @param {Book} output + * @param {Page} page + * @return {Object} + */ function encodeBookWithPage(book, page) { var file = page.getFile(); diff --git a/lib/json/encodeOutput.js b/lib/json/encodeOutput.js index 9054124..7347e57 100644 --- a/lib/json/encodeOutput.js +++ b/lib/json/encodeOutput.js @@ -1,11 +1,11 @@ var encodeBook = require('./encodeBook'); /** - Encode an output to JSON - - @param {Output} - @return {Object} -*/ + * Encode an output to JSON + * + * @param {Output} + * @return {Object} + */ function encodeOutputToJson(output) { var book = output.getBook(); var generator = output.getGenerator(); diff --git a/lib/json/encodeOutputWithPage.js b/lib/json/encodeOutputWithPage.js new file mode 100644 index 0000000..8b21e3d --- /dev/null +++ b/lib/json/encodeOutputWithPage.js @@ -0,0 +1,23 @@ +var encodeOutput = require('./encodeOutput'); +var encodePage = require('./encodePage'); +var encodeFile = require('./encodeFile'); + +/** + * Return a JSON representation of a book with a specific file + * + * @param {Book} output + * @param {Page} page + * @return {Object} + */ +function encodeOutputWithPage(output, page) { + var file = page.getFile(); + var book = output.getBook(); + + var result = encodeOutput(output); + result.page = encodePage(page, book.getSummary()); + result.file = encodeFile(file); + + return result; +} + +module.exports = encodeOutputWithPage; diff --git a/lib/json/index.js b/lib/json/index.js index 4387ae0..3b68f5e 100644 --- a/lib/json/index.js +++ b/lib/json/index.js @@ -2,6 +2,7 @@ module.exports = { encodeOutput: require('./encodeOutput'), encodeBookWithPage: require('./encodeBookWithPage'), + encodeOutputWithPage: require('./encodeOutputWithPage'), encodeBook: require('./encodeBook'), encodeFile: require('./encodeFile'), encodePage: require('./encodePage'), |