diff options
author | Samy Pessé <samypesse@gmail.com> | 2016-06-07 10:26:28 +0200 |
---|---|---|
committer | Samy Pessé <samypesse@gmail.com> | 2016-06-07 10:26:28 +0200 |
commit | 7178ab1f82616862edb3a53291aef155be66a4b7 (patch) | |
tree | 9a92d268eb3020cab29c68d257629beb6d1e2ac2 /lib/models/config.js | |
parent | bf895b707e6cc4ca5fdf4ade5bb9235f1b1b99ca (diff) | |
download | gitbook-7178ab1f82616862edb3a53291aef155be66a4b7.zip gitbook-7178ab1f82616862edb3a53291aef155be66a4b7.tar.gz gitbook-7178ab1f82616862edb3a53291aef155be66a4b7.tar.bz2 |
Improve Config.toText to return only the required fields
Diffstat (limited to 'lib/models/config.js')
-rw-r--r-- | lib/models/config.js | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/lib/models/config.js b/lib/models/config.js index 00d2b47..6de52f9 100644 --- a/lib/models/config.js +++ b/lib/models/config.js @@ -4,6 +4,7 @@ var Immutable = require('immutable'); var File = require('./file'); var PluginDependency = require('./pluginDependency'); var configDefault = require('../constants/configDefault'); +var reducedObject = require('../utils/reducedObject'); var Config = Immutable.Record({ file: File(), @@ -19,11 +20,20 @@ Config.prototype.getValues = function() { }; /** + * Return minimum version of configuration, + * Basically it returns the current config minus the default one + * @return {Map} + */ +Config.prototype.toReducedVersion = function() { + return reducedObject(configDefault, this.getValues()); +}; + +/** * Render config as text * @return {Promise<String>} */ Config.prototype.toText = function() { - return JSON.stringify(this.getValues().toJS(), null, 4); + return JSON.stringify(this.toReducedVersion().toJS(), null, 4); }; /** |