Event emitter for daily events like sunrise, sunset, dawn, dusk, etc.
DayEvents is an EventEmitter that will emit events as they happen during the day, in real time. The events come from the SunCalc library and documented constants are included.
const{
DayEvents,eventNames: {SUNRISE,SUNSET}}=require('day-events');letlatitude=45.5231;letlongitude=-122.6765;lettoday=newDayEvents(latitude,longitude);today.on(SUNRISE,()=>console.log('Good morning!'));today.on(SUNSET,()=>console.log('Good evening!'));leteventTimes=today.getTimes();console.log(`Sunset is at ${eventTimes[SUNSET].toString()}`);