Skip to content

Instantly share code, notes, and snippets.

@rviscomi
Created May 10, 2017 18:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rviscomi/0ed73516c2022a80167c09216b9f8f9a to your computer and use it in GitHub Desktop.
Save rviscomi/0ed73516c2022a80167c09216b9f8f9a to your computer and use it in GitHub Desktop.
Helper script for adding events to the HTTP Archive changelog.json file
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