From 42ec04e2c8036f459addda43e0654a1a4b77cfd4 Mon Sep 17 00:00:00 2001 From: Stephan Porada Date: Mon, 12 Oct 2020 11:07:51 +0200 Subject: [PATCH] User ...args instead of arguments object --- .../modules/corpus_analysis/client/Client.js | 4 ++-- .../corpus_analysis/client/callbacks.js | 21 +++++++++---------- .../modules/corpus_analysis/view/listeners.js | 1 - 3 files changed, 12 insertions(+), 14 deletions(-) diff --git a/web/app/static/js/modules/corpus_analysis/client/Client.js b/web/app/static/js/modules/corpus_analysis/client/Client.js index bd1ac2ee..6d8a54e3 100644 --- a/web/app/static/js/modules/corpus_analysis/client/Client.js +++ b/web/app/static/js/modules/corpus_analysis/client/Client.js @@ -256,8 +256,8 @@ class ClientEventListener { // Executes a specific registered callback by provoding a type string. executeCallback(defaultArgs, type) { let listenerCallback = this.listenerCallbacks[type]; - listenerCallback.callbackFunction(...defaultArgs, - ...listenerCallback.args); + let args = defaultArgs.concat(listenerCallback.args) ; + listenerCallback.callbackFunction(...args); } } diff --git a/web/app/static/js/modules/corpus_analysis/client/callbacks.js b/web/app/static/js/modules/corpus_analysis/client/callbacks.js index 7a50726d..e2838204 100644 --- a/web/app/static/js/modules/corpus_analysis/client/callbacks.js +++ b/web/app/static/js/modules/corpus_analysis/client/callbacks.js @@ -2,9 +2,8 @@ * This callback is called on a socket.on "corpus_analysis_send_meta_data". * Handels incoming corpus metadata */ -// TODO: rework arguments to ...args -function saveMetaData() { - let [payload, client, results, rest] = arguments; +function saveMetaData(...args) { + let [payload, client, results, rest] = args; client.notifyView('meta-data-recieving'); results.metaData.init(payload) console.info('Metada saved:', results); @@ -18,9 +17,9 @@ function saveMetaData() { * and does some preperation work like hiding or showing elements and deleting * the data from the last query. */ -function prepareQueryData() { +function prepareQueryData(...args) { // deletes old data from query issued before this new query - let [payload, client, results, rest] = arguments; + let [payload, client, results, rest] = args; // always initialize the results to delete data from the query issued before results.init(); results.data.match_count = payload.match_count; @@ -31,8 +30,8 @@ function prepareQueryData() { /** * This callbacks saves the incoming query data chunks into the model results. */ -function saveQueryData() { - let [payload, client, results, rest] = arguments; +function saveQueryData(...args) { + let [payload, client, results, rest] = args; // Get data matches length before new chunk data is being inserted let dataLength = results.data.matches.length; if (client.dynamicMode) { @@ -94,8 +93,8 @@ function saveQueryData() { * from the already present results.data. Result data is identified with the * dataIndexes. On index is one match. */ -function getResultsData() { - let [resultsType, dataIndexes, resultsList, client, results, rest] = arguments; +function getResultsData(...args) { + let [resultsType, dataIndexes, resultsList, client, results, rest] = args; client.isBusy = true; if (resultsList.exportFullInspectContext.checked || resultsType === 'inspect-results') { @@ -112,8 +111,8 @@ function getResultsData() { * Handles incoming results which have been requested via getResultsData(). and * saves the data accorindgly into the results object. */ -function saveResultsData() { - let [payload, type, client, results, rest] = arguments; +function saveResultsData(...args) { + let [payload, type, client, results, rest] = args; let objectKey = ''; if (type === 'full-results') { console.info('Saving full-results data.'); diff --git a/web/app/static/js/modules/corpus_analysis/view/listeners.js b/web/app/static/js/modules/corpus_analysis/view/listeners.js index 5df70baa..812c125b 100644 --- a/web/app/static/js/modules/corpus_analysis/view/listeners.js +++ b/web/app/static/js/modules/corpus_analysis/view/listeners.js @@ -250,7 +250,6 @@ function showCorpusFiles(resultsList, results) { valueNames: ["title", "year", "match-count"], }; let corpusFileTable = new List('corpus-file-table', options); - console.log(corpusFileTable); } }