forked from Yiler7274/Konduktiva-github-test
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutilities-general.js
27 lines (23 loc) · 923 Bytes
/
utilities-general.js
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
// --------------------------------------------------------------------------
// -- utilities-array.js
// -- initial author: Renick Bell ([email protected])
// -- initial creation date: Fri Jul 7 10:57 AM CST 2023
// -- contributors: Yiler Huang ([email protected]); Steve Wang ([email protected])
// -- license: GPL 3.0
// --------------------------------------------------------------------------
function steveRoundOff(number, decimalPlaces) {
let roundedNumber = number.toFixed(decimalPlaces);
return JSON.parse(roundedNumber)
}
function steveRandomRange(min, max, decimalPlaces) {
if (decimalPlaces == undefined) {
decimalPlaces = 0
}
return steveRoundOff(min + (max - min) * (Math.random()), decimalPlaces);
}
function barsToBeats(beatsPerBar, inputBars) {
return inputBars.map(e => e *= beatsPerBar)
}
function add2Log(info) {
fs.appendFileSync('logs.txt', info + '\n')
}