Created
September 11, 2017 19:44
-
-
Save zrrrzzt/06869dc8a86a2dfcb5f16583c83dd9b8 to your computer and use it in GitHub Desktop.
Resten av valglys-koden
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'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