Skip to content

Instantly share code, notes, and snippets.

@IUnknown68
Created June 18, 2015 13:21
Show Gist options
  • Save IUnknown68/ae7f570d242aa984035b to your computer and use it in GitHub Desktop.
Save IUnknown68/ae7f570d242aa984035b to your computer and use it in GitHub Desktop.
Small algorithm for getting a list of latest versions from a version history.
var g = [
{
v: '1.0.0',
f: ['README.md', 'new/images/image1.jpg','new/images/image2.jpg','new/images/image3.jpg']
},
{
v: '0.2.0',
f: ['README.md', 'foo/bar/bar.txt']
},
{
v: '0.1.0',
f: ['README.md', 'foo/bar/bar.txt','foo/foo.txt']
}
];
var files = {};
g.forEach(function(version) {
version.f.forEach(function(file) {
if (!files[file]) {
files[file] = version.v;
}
});
});
console.log(files);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment