Created
June 18, 2015 13:21
-
-
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.
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
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