Skip to content

Commit 2efb20b

Browse files
committed
moved parseOptions into utilities module
1 parent a498f21 commit 2efb20b

2 files changed

Lines changed: 14 additions & 15 deletions

File tree

services/tone_analyzer/v3.js

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -85,20 +85,6 @@ module.exports = function (RED) {
8585
};
8686

8787

88-
// function to parse through the options in preparation
89-
// for the sevice call.
90-
var parseOptions = function (msg, config) {
91-
var options = {
92-
'text': msg.payload,
93-
'sentences': msg.sentences || config.sentences,
94-
'isHTML': msg.contentType || config.contentType
95-
};
96-
97-
options.tones = toneutils.parseToneOption(msg, config);
98-
return options;
99-
}
100-
101-
10288
// function when the node recieves input inside a flow.
10389
// Configuration is first checked before the service is invoked.
10490
var processOnInput = function(msg, config, node) {
@@ -115,7 +101,7 @@ module.exports = function (RED) {
115101
'version_date': '2016-05-19'
116102
});
117103

118-
var options = parseOptions(msg, config);
104+
var options = toneutils.parseOptions(msg, config);
119105

120106
node.status({fill:'blue', shape:'dot', text:'requesting'});
121107
tone_analyzer.tone(options, function (err, response) {

utilities/tone-utils.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,19 @@ ToneUtils.prototype = {
5151
var tones = msg.tones || config.tones;
5252

5353
return (tones === 'all' ? '' : tones);
54+
},
55+
56+
// function to parse through the options in preparation
57+
// for the sevice call.
58+
parseOptions: function(msg, config) {
59+
var options = {
60+
'text': msg.payload,
61+
'sentences': msg.sentences || config.sentences,
62+
'isHTML': msg.contentType || config.contentType
63+
};
64+
65+
options.tones = toneutils.parseToneOption(msg, config);
66+
return options;
5467
}
5568

5669

0 commit comments

Comments
 (0)