summaryrefslogtreecommitdiffstats
path: root/lib/json/encodeSummary.js
diff options
context:
space:
mode:
authorSamy Pesse <samypesse@gmail.com>2016-04-23 17:10:16 +0200
committerSamy Pesse <samypesse@gmail.com>2016-04-23 17:10:16 +0200
commite1fa977b5b1b3c03790de6e2c21ee39ba55d9555 (patch)
treea1ad4386100b5779ef930845093c14639a3353b5 /lib/json/encodeSummary.js
parentce95f316b9ce1eac1e615db3540c4d0f30408d63 (diff)
downloadgitbook-e1fa977b5b1b3c03790de6e2c21ee39ba55d9555.zip
gitbook-e1fa977b5b1b3c03790de6e2c21ee39ba55d9555.tar.gz
gitbook-e1fa977b5b1b3c03790de6e2c21ee39ba55d9555.tar.bz2
Add json encoding utils
Diffstat (limited to 'lib/json/encodeSummary.js')
-rw-r--r--lib/json/encodeSummary.js20
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/json/encodeSummary.js b/lib/json/encodeSummary.js
new file mode 100644
index 0000000..97db910
--- /dev/null
+++ b/lib/json/encodeSummary.js
@@ -0,0 +1,20 @@
+var encodeFile = require('./encodeFile');
+var encodeSummaryPart = require('./encodeSummaryPart');
+
+/**
+ Encode a summary to JSON
+
+ @param {Summary}
+ @return {Object}
+*/
+function encodeSummary(summary) {
+ var file = summary.getFile();
+ var parts = summary.getParts();
+
+ return {
+ file: encodeFile(file),
+ parts: parts.map(encodeSummaryPart).toJS()
+ };
+}
+
+module.exports = encodeSummary;