Created
May 10, 2017 18:28
-
-
Save rviscomi/0ed73516c2022a80167c09216b9f8f9a to your computer and use it in GitHub Desktop.
Helper script for adding events to the HTTP Archive changelog.json file
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
class HAChangelog { | |
constructor(changelog=[]) { | |
this.changelog = changelog; | |
} | |
add(datestr, title, desc) { | |
this.changelog.push({ | |
date: (new Date(datestr)).getTime(), | |
title, | |
desc | |
}); | |
return this.changelog; | |
} | |
sort() { | |
this.changelog = this.changelog.sort((a, b) => { | |
return a.date > b.date; | |
}); | |
} | |
toJSON() { | |
this.sort(); | |
return JSON.stringify(this.changelog, null, 4); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment