Total Complexity | 5 |
Complexity/F | 1.25 |
Lines of Code | 30 |
Function Count | 4 |
Duplicated Lines | 0 |
Ratio | 0 % |
Changes | 4 | ||
Bugs | 0 | Features | 0 |
1 | /** |
||
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); |
||
|
|||
37 | }); |
||
38 | }); |
||
39 | } |
||
40 | |||
41 | RED.nodes.registerType('say', SayNode); |
||
42 | }; |
||
43 |