say.js   A
last analyzed

Complexity

Total Complexity 5
Complexity/F 1.25

Size

Lines of Code 30
Function Count 4

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 4
Bugs 0 Features 0
Metric Value
cc 0
c 4
b 0
f 0
nc 2
dl 0
loc 30
rs 10
wmc 5
mnd 1
bc 5
fnc 4
bpm 1.25
cpm 1.25
noi 1
1
/**
2
 * Node
3
 *
4
 * LICENSE:    MIT
5
 *
6
 * @project    node-red-contrib-say
7
 * @package    NodeRedNode
8
 * @author     André Lademann <[email protected]>
9
 * @copyright  Copyright (c) 2014 programmerq.eu (http://programmerq.eu)
10
 * @license    http://programmerq.eu/license
11
 * @since      2014-11-27 - 08:53:21 AM
12
 */
13
module.exports = function (RED) {
14
	'use strict';
15
16
	var say = require('say');
17
18
	/**
19
	 * Say node
20
	 *
21
	 * @property {*} config Configuration object
22
	 * @return void
23
	 **/
24
	function SayNode(config) {
25
		RED.nodes.createNode(this, config);
26
		var node = this;
27
		this.on('input', function (msg) {
28
			say.speak(
29
				this.name || msg.payload,
30
				this.voice,
31
				1,
32
				function(err) {
33
					if (err) {
34
				    return node.error(err);
35
				  }
36
				node.send(msg);
0 ignored issues
show
Best Practice introduced by
There is no return statement in this branch, but you do return something in other branches. Did you maybe miss it? If you do not want to return anything, consider adding return undefined; explicitly.
Loading history...
37
			});
38
		});
39
	}
40
41
	RED.nodes.registerType('say', SayNode);
42
};
43