From bdfc115a0a8b773fecbd46e86f5216589ba1c8d4 Mon Sep 17 00:00:00 2001 From: Paulin Jorys Date: Wed, 19 Jul 2017 18:08:43 +0200 Subject: [PATCH] Added basic jsdoc for the messages.js file --- static/js/messages.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/static/js/messages.js b/static/js/messages.js index e442029..9ea552e 100644 --- a/static/js/messages.js +++ b/static/js/messages.js @@ -1,6 +1,13 @@ var callbacks = {} var callbacks_ids = 1; +/** + * var sendMessage - Sends a message with arguments to the NaCl module + * + * @param {String} method A named method + * @param {(String|Array)} params An array of options or a signle string + * @return {void} The NaCl module calls back trought the handleMessage method + */ var sendMessage = function(method, params) { return new Promise(function(resolve, reject) { var id = callbacks_ids++; @@ -14,6 +21,12 @@ var sendMessage = function(method, params) { }); } +/** + * handleMessage - Handles messages from the NaCl module + * + * @param {Object} msg An object given by the NaCl module + * @return {void} + */ function handleMessage(msg) { if (msg.data.callbackId && callbacks[msg.data.callbackId]) { // if it's a callback, treat it as such callbacks[msg.data.callbackId][msg.data.type](msg.data.ret);