Skip to content

Instantly share code, notes, and snippets.

@zrrrzzt
Created September 11, 2017 19:44
Show Gist options
  • Save zrrrzzt/06869dc8a86a2dfcb5f16583c83dd9b8 to your computer and use it in GitHub Desktop.
Save zrrrzzt/06869dc8a86a2dfcb5f16583c83dd9b8 to your computer and use it in GitHub Desktop.
Resten av valglys-koden
'use strict'
const setColor = require('./changecolor')
const getMandater = require('./get-mandater')
const switchColor = async color => {
try {
const result = await setColor(color)
console.log(result)
} catch (error) {
console.error(error)
}
}
const getColor = async () => {
try {
const mandater = await getMandater()
return mandater.red > mandater.blue ? 'red' : 'blue'
} catch (error) {
console.error(error)
return 'white'
}
}
const setLight = async () => {
try {
const color = await getColor()
switchColor(color)
} catch (error) {
console.error(error)
}
}
setInterval(() => setLight(), 1000*60*10)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment