-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathutils.js
More file actions
32 lines (26 loc) · 838 Bytes
/
utils.js
File metadata and controls
32 lines (26 loc) · 838 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
const os = require('os');
const UTILS = {
getLocalIpAddress() {
const interfaces = os.networkInterfaces();
for (const interfaceName in interfaces) {
const _interface = interfaces[interfaceName];
for (const interfaceInfo of _interface) {
if (interfaceInfo.family === 'IPv4' && !interfaceInfo.internal) {
return interfaceInfo.address;
}
}
}
return null; // Return null if no IP address is found
},
split_channels(data, channels){
//split stereo mp3 data into 2 channels
var left = []
var right = []
for(var i = 0; i < data.length; i+=2){
left.push(data[i])
right.push(data[i+1])
}
return {left:left, right:right}
}
}
module.exports = UTILS;