Sun calculation js library which is fully based on formula from http://aa.quae.nl/en/reken/zonpositie.html
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
867 B
34 lines
867 B
module.exports = eventsToArray
|
|
|
|
var EE = require('events').EventEmitter
|
|
function eventsToArray (ee, ignore, map) {
|
|
ignore = ignore || []
|
|
map = map || function (x) { return x }
|
|
var array = []
|
|
|
|
ee.emit = (function (orig) {
|
|
return function etoaWrap (ev) {
|
|
if (ignore.indexOf(ev) === -1) {
|
|
var l = arguments.length
|
|
var args = new Array(l)
|
|
// intentionally sparse array
|
|
var swap = []
|
|
for (var i = 0; i < l; i++) {
|
|
var arg = arguments[i]
|
|
args[i] = arguments[i]
|
|
if (arg instanceof EE)
|
|
swap[i] = eventsToArray(arg, ignore, map)
|
|
}
|
|
args = args.map(map)
|
|
args = args.map(function (arg, index) {
|
|
return swap[index] || arg
|
|
})
|
|
array.push(args)
|
|
}
|
|
|
|
return orig.apply(this, arguments)
|
|
}
|
|
})(ee.emit)
|
|
|
|
return array
|
|
}
|
|
|