• Sean Hammond's avatar
    Turn the settings obj into a settingsFrom function · ae3e804a
    Sean Hammond authored
    annotator.config.settings currently exports an object containing
    individual standalone functions for returning different settings'
    values:
    
        module.exports = {
          app: appFunction,
          annotations: annotationsFunction,
          ...
        };
    
    Change it to export just a single constructor function - settingsFrom()
    - that returns an object containing the previously-exported functions as
    methods:
    
        function settingsFrom(window_) {
          ...
          return {
            get app() { return app(); },
            get annotations() { return annotations(); },
            ...
          };
        }
    
        module.exports = settingsFrom;
    
    Note that ES5 getters are used so that, even though app() and
    annotations() are methods rather than simple properties now, they can
    still be accessed as properties - settings.app not settings.app(). This
    makes the code that uses this object slightly simpler, and makes mocking
    this object in unit tests simpler.
    
    The diff of this commit looks big, because the indentation of a lot of
    code is changed, but it really is just changing functions into methods
    and not actually changing the code of any of those functions.
    
    The reason for turning functions into an object with methods is so that
    the object that settingsFrom() returns can have state (by having closure
    variables inside the settingsFrom() function). We don't make any use of
    this state yet but future commits will do.
    ae3e804a
Name
Last commit
Last update
.github Loading commit data...
docs Loading commit data...
images Loading commit data...
scripts Loading commit data...
src Loading commit data...
.babelrc Loading commit data...
.eslintignore Loading commit data...
.eslintrc Loading commit data...
.gitignore Loading commit data...
.npmignore Loading commit data...
.npmrc Loading commit data...
.travis.yml Loading commit data...
CHANGELOG.md Loading commit data...
CODE_OF_CONDUCT Loading commit data...
Jenkinsfile Loading commit data...
LICENSE Loading commit data...
Makefile Loading commit data...
README.md Loading commit data...
gulpfile.js Loading commit data...
package.json Loading commit data...
requirements-dev.in Loading commit data...
yarn.lock Loading commit data...