-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathhelper.js
executable file
·43 lines (37 loc) · 1.07 KB
/
helper.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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// MATH STUFF
function isInRangeInclusinve(min, max, num) {
if (num >= min && num <= max){
return true
} else {
return false
}
}
// Other
function shareAnElement(arrayOne, arrayTwo){
var match = false
for (iOne in arrayOne){
var currentElement = arrayOne[iOne].toLowerCase()
for (iTwo in arrayTwo){
if (currentElement == arrayTwo[iTwo].toLowerCase()){
match = true
}
}
}
return match
}
//Hive STUFF
let hive = require("@hiveio/hive-js")
hive.api.setOptions({url: 'https://anyx.io'})
function getVPOfAccount(account, callback){
hive.api.getAccounts([account], function (err, response) {
var secondsago = (new Date - new Date(response[0].last_vote_time + "Z")) / 1000;
var vpow = response[0].voting_power + (10000 * secondsago / 432000);
var vp = Math.min(vpow / 100, 100).toFixed(2);
callback(vp)
})
}
module.exports = {
isInRangeInclusinve : isInRangeInclusinve,
shareAnElement: shareAnElement,
getVPOfAccount: getVPOfAccount
}