Use lodash in place of underscore

This commit is contained in:
Steve Purcell 2013-09-04 09:54:07 +01:00
parent 12747bb860
commit 958b769de8
2 changed files with 7 additions and 7 deletions

View file

@ -56,7 +56,7 @@
</main> </main>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.1.5/angular.min.js"></script> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.1.5/angular.min.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/moment.js/2.0.0/moment.min.js"></script> <script src="http://cdnjs.cloudflare.com/ajax/libs/moment.js/2.0.0/moment.min.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.5.1/underscore-min.js"></script> <script src="http://cdnjs.cloudflare.com/ajax/libs/lodash.js/1.3.1/lodash.min.js"></script>
<script src="js/melpa.js"></script> <script src="js/melpa.js"></script>
<script src="http://platform.twitter.com/widgets.js" type="text/javascript" async="async"></script> <script src="http://platform.twitter.com/widgets.js" type="text/javascript" async="async"></script>
<script type="text/javascript"> <script type="text/javascript">

View file

@ -40,14 +40,14 @@
return null; return null;
}; };
var listed = _.intersection(_(info.archive.data).keys(), _(info.recipes.data).keys()); var listed = _.intersection(_.keys(info.archive.data), _.keys(info.recipes.data));
return _(listed).reduce(function(pkgs, name) { return _(listed).reduce(function(pkgs, name) {
var built = info.archive.data[name]; var built = info.archive.data[name];
var recipe = info.recipes.data[name]; var recipe = info.recipes.data[name];
var descr = built[2].replace(/\s*\[((?:source: )?\w+)\]$/, ""); var descr = built[2].replace(/\s*\[((?:source: )?\w+)\]$/, "");
var version = built[0].join("."); var version = built[0].join(".");
// Fix up hokey deps, which look like {"clojure-mode":{"2":[0,0]}} for 2.0.0 // Fix up hokey deps, which look like {"clojure-mode":{"2":[0,0]}} for 2.0.0
var deps = _(built[1] || {}).map(function (val, name) { var deps = _.map(built[1] || {}, function (val, name) {
var v1 = _.keys(val)[0]; var v1 = _.keys(val)[0];
return {name: name, version: [v1].concat(val[v1] || []).join('.')}; return {name: name, version: [v1].concat(val[v1] || []).join('.')};
}); });
@ -75,8 +75,8 @@
dependenciesOn: function(name) { dependenciesOn: function(name) {
return packages.then(function(pkgs) { return packages.then(function(pkgs) {
return _(pkgs).values().filter(function(p) { return _.values(pkgs).filter(function(p) {
return _(p.dependencies).findWhere({name: name}); return _.findWhere(p.dependencies, {name: name});
}); });
}); });
}, },
@ -96,8 +96,8 @@
$scope.orderBy = "name"; $scope.orderBy = "name";
$scope.searchTerms = $routeParams.q; $scope.searchTerms = $routeParams.q;
packageService.getPackages().then(function(pkgs){ packageService.getPackages().then(function(pkgs){
$scope.packages = _(pkgs).values(); $scope.packages = _.values(pkgs);
$scope.totalDownloads = _.reduce(_($scope.packages).pluck("downloads"), function (a, b) { return b === undefined ? a : a + b; }, 0); $scope.totalDownloads = _.reduce(_.pluck($scope.packages, "downloads"), function (a, b) { return b === undefined ? a : a + b; }, 0);
}); });
$scope.packageMatcher = function(term) { $scope.packageMatcher = function(term) {
var t = term && term.toLowerCase(); var t = term && term.toLowerCase();