• 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
..
anchoring Loading commit data...
config Loading commit data...
plugin Loading commit data...
test Loading commit data...
util Loading commit data...
vendor Loading commit data...
.eslintrc.js Loading commit data...
adder.html Loading commit data...
adder.js Loading commit data...
annotation-counts.js Loading commit data...
annotation-sync.js Loading commit data...
delegator.coffee Loading commit data...
guest.coffee Loading commit data...
highlighter.coffee Loading commit data...
host.coffee Loading commit data...
main.js Loading commit data...
pdf-sidebar.coffee Loading commit data...
pdfjs-rendering-states.js Loading commit data...
plugin.coffee Loading commit data...
range-util.js Loading commit data...
selections.js Loading commit data...
sidebar-trigger.js Loading commit data...
sidebar.coffee Loading commit data...