Created
May 4, 2017 19:41
-
-
Save rviscomi/31916a648679b64532d3612356807792 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
parseReleaseHistory = (table) => { | |
const rows = Array.from(table.querySelectorAll('tbody tr')); | |
return rows.reduce((dates, row) => { | |
let version = getVersion(row.querySelector('td:nth-child(1)').innerText); | |
let date = getDate(row.querySelector('td:nth-child(2)').innerText); | |
dates.push({version, date}); | |
const patch = row.querySelector('td:nth-child(3)').innerText; | |
if (patch) { | |
let _; | |
[_, version, date] = patch.match(/([\d\.]+) \((.*)\)/) | |
version = getVersion(version); | |
date = getDate(date); | |
dates.push({version, date}); | |
} | |
return dates; | |
}, []); | |
}; | |
getVersion = (versionStr) => versionStr.match(/\d+\.?\d+\.?\d*/)[0]; | |
getDate = (dateStr) => { | |
const d = new Date(dateStr.replace(/\u00A0/g, ' ')); | |
return `${d.getFullYear()}-${d.getMonth()+1}-${d.getDate()}`; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment