Skip to content

Commit cc72d35

Browse files
committed
Move definition
So we don't have to fudge the jsdoc to make the linter happy
1 parent 267e009 commit cc72d35

File tree

1 file changed

+23
-30
lines changed

1 file changed

+23
-30
lines changed

lib/pushprocessor.js

Lines changed: 23 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -17,28 +17,6 @@ limitations under the License.
1717
* @module pushprocessor
1818
*/
1919

20-
/**
21-
* Convert a list of actions into a object with the actions as keys and their values
22-
* eg. [ 'notify', { set_tweak: 'sound', value: 'default' } ]
23-
* becomes { notify: true, tweaks: { sound: 'default' } }
24-
* @param {array} actionlist The actions list
25-
*
26-
* @return {object} A object with key 'notify' (true or false) and an object of actions
27-
*/
28-
function actionListToActionsObject(actionlist) {
29-
var actionobj = { 'notify': false, 'tweaks': {} };
30-
for (var i = 0; i < actionlist.length; ++i) {
31-
var action = actionlist[i];
32-
if (action === 'notify') {
33-
actionobj.notify = true;
34-
} else if (typeof action === 'object') {
35-
if (action.value === undefined) { action.value = true; }
36-
actionobj.tweaks[action.set_tweak] = action.value;
37-
}
38-
}
39-
return actionobj;
40-
}
41-
4220
/**
4321
* Construct a Push Processor.
4422
* @constructor
@@ -269,7 +247,7 @@ function PushProcessor(client) {
269247
var rule = matchingRuleForEventWithRulesets(ev, rulesets);
270248
if (!rule) { return {}; }
271249

272-
var actionObj = actionListToActionsObject(rule.actions);
250+
var actionObj = PushProcessor.actionListToActionsObject(rule.actions);
273251

274252
// Some actions are implicit in some situations: we add those here
275253
if (actionObj.tweaks.highlight === undefined) {
@@ -293,6 +271,28 @@ function PushProcessor(client) {
293271
};
294272
}
295273

274+
/**
275+
* Convert a list of actions into a object with the actions as keys and their values
276+
* eg. [ 'notify', { set_tweak: 'sound', value: 'default' } ]
277+
* becomes { notify: true, tweaks: { sound: 'default' } }
278+
* @param {array} actionlist The actions list
279+
*
280+
* @return {object} A object with key 'notify' (true or false) and an object of actions
281+
*/
282+
PushProcessor.actionListToActionsObject = function(actionlist) {
283+
var actionobj = { 'notify': false, 'tweaks': {} };
284+
for (var i = 0; i < actionlist.length; ++i) {
285+
var action = actionlist[i];
286+
if (action === 'notify') {
287+
actionobj.notify = true;
288+
} else if (typeof action === 'object') {
289+
if (action.value === undefined) { action.value = true; }
290+
actionobj.tweaks[action.set_tweak] = action.value;
291+
}
292+
}
293+
return actionobj;
294+
};
295+
296296
/**
297297
* @typedef {Object} PushAction
298298
* @type {Object}
@@ -307,10 +307,3 @@ function PushProcessor(client) {
307307
/** The PushProcessor class. */
308308
module.exports = PushProcessor;
309309

310-
/**
311-
* See above
312-
* @param {array} actionlist The actions list
313-
*
314-
* @return {object} See above
315-
*/
316-
module.exports.actionListToActionsObject = actionListToActionsObject;

0 commit comments

Comments
 (0)