refactoring of getModules function

This commit is contained in:
azivner
2018-03-04 12:06:35 -05:00
parent 7a865a9081
commit d239ef2956
3 changed files with 58 additions and 54 deletions

View File

@@ -9,21 +9,16 @@ const config = require('./config');
const Repository = require('./repository');
const axios = require('axios');
function ScriptContext(dataKey, note, allNotes) {
function ScriptContext(dataKey, startNote, allNotes) {
dataKey = protected_session.getDataKey(dataKey);
const repository = new Repository(dataKey);
this.axios = axios;
this.__startNote = note;
this.__notes = {};
if (allNotes) {
allNotes.forEach(note => this.__notes[note.noteId] = note);
}
this.__startNote = startNote;
this.__notes = utils.toObject(allNotes, note => [note.noteId, note]);
this.__modules = {};
this.axios = axios;
this.utils = {
unescapeHtml: utils.unescapeHtml,
isoDateTimeStr: utils.dateStr