summaryrefslogtreecommitdiffstats
path: root/packages/gitbook/src/json/encodeSummary.js
diff options
context:
space:
mode:
Diffstat (limited to 'packages/gitbook/src/json/encodeSummary.js')
-rw-r--r--packages/gitbook/src/json/encodeSummary.js20
1 files changed, 20 insertions, 0 deletions
diff --git a/packages/gitbook/src/json/encodeSummary.js b/packages/gitbook/src/json/encodeSummary.js
new file mode 100644
index 0000000..9a07da4
--- /dev/null
+++ b/packages/gitbook/src/json/encodeSummary.js
@@ -0,0 +1,20 @@
+const encodeFile = require('./encodeFile');
+const encodeSummaryPart = require('./encodeSummaryPart');
+
+/**
+ Encode a summary to JSON
+
+ @param {Summary}
+ @return {Object}
+*/
+function encodeSummary(summary) {
+ const file = summary.getFile();
+ const parts = summary.getParts();
+
+ return {
+ file: encodeFile(file),
+ parts: parts.map(encodeSummaryPart).toJS()
+ };
+}
+
+module.exports = encodeSummary;