Created
May 25, 2021 20:36
-
-
Save pszafer/614a5501b386e7b6b4ae97f26642f95f to your computer and use it in GitHub Desktop.
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
const input = JSON.parse(msg.data.replace("eval(", "").replace(",],", "],").slice(0, -1)); | |
const today = new Date() | |
const data_d = today.getDay(); | |
const data_m = today.getMonth()+1; | |
const smieci = ["makulatura", "szklo", "zielone","kuchenne","resztkowe", "mix", "gabaryty" ] | |
const inputSortedByKind = input["dane"].reduce((acc, curr) => { | |
acc[curr["rodzaj"]].push(new Date(2021, +curr["data_m"]-1, +curr["data_d"])) | |
return acc | |
}, { | |
"makulatura": [], "szklo": [], "zielone": [],"kuchenne": [],"resztkowe": [], "mix": [], "gabaryty": [] | |
}) | |
for (var smiec of smieci){ | |
let found = inputSortedByKind[smiec].find(e => e >= today) | |
if (found){ | |
msg[smiec] = found | |
} | |
} | |
msg.data = null; | |
return msg; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment