21 lines
686 B
JavaScript
21 lines
686 B
JavaScript
// Temperatures below the identity point count as night light. Keep in sync
|
|
// with bin/blob-toggle-nightlight, which applies the same threshold.
|
|
var IDENTITY_TEMPERATURE = 6000
|
|
|
|
function temperatureFromOutput(output) {
|
|
var match = String(output === undefined || output === null ? "" : output).match(/[0-9]+/)
|
|
return match ? Number(match[0]) : null
|
|
}
|
|
|
|
function isNightlight(temperature) {
|
|
return temperature !== null && temperature !== undefined && temperature < IDENTITY_TEMPERATURE
|
|
}
|
|
|
|
if (typeof module !== "undefined") {
|
|
module.exports = {
|
|
IDENTITY_TEMPERATURE: IDENTITY_TEMPERATURE,
|
|
temperatureFromOutput: temperatureFromOutput,
|
|
isNightlight: isNightlight
|
|
}
|
|
}
|