-
Notifications
You must be signed in to change notification settings - Fork 0
/
ComputingActor.js
40 lines (31 loc) · 926 Bytes
/
ComputingActor.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
const APIXU_TOKEN = '' // Add your token
class ComputingActor {
async getCurrenWheather(city) {
const axios = require('axios')
let res = await axios.get(`http://api.apixu.com/v1/current.json?key=${APIXU_TOKEN}&q=` + city)
let text = res.data.current.condition.text
let temp = res.data.current.temp_c
let result = `Weather from ${process.pid}: ${text}, ${temp > 0 ? '+' + temp : temp}C`
console.log(result)
return result
}
getPrime(num) {
let primesCount = 0
let current = 1
while (primesCount !== Number(num)) {
current++
let isPrime = true
for (let j = 2; j < current; j++) {
if (current % j === 0) {
isPrime = false
break
}
}
if (isPrime)
primesCount++
}
console.log(`Prime from ${process.pid} is ${current}`)
return current
}
}
module.exports.ComputingActor = ComputingActor