Skip to content

Commit

Permalink
Extract duplicated filter functions
Browse files Browse the repository at this point in the history
  • Loading branch information
lonelyghost committed Nov 16, 2019
1 parent 250ebf9 commit 82dbe65
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions app/components/dependency-tables.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import Component from '@ember/component';
import { inject as service } from '@ember/service';

const dependencies = (dep) => dep.isDependency;
const devDependencies = (dep) => dep.isDevDependency;

export default Component.extend({
tagName: '',

Expand All @@ -15,8 +18,8 @@ export default Component.extend({
sort: 'package',
}).then((results) => {
return {
dependencies: results.filter((dep) => dep.isDependency).map((dep) => dep.package),
devDependencies: results.filter((dep) => dep.isDevDependency).map((dep) => dep.package)
dependencies: results.filter(dependencies).map(dep => dep.package),
devDependencies: results.filter(devDependencies).map(dep => dep.package)
};
});
},
Expand All @@ -27,8 +30,8 @@ export default Component.extend({
include: 'dependent-version',
}).then((results) => {
return {
dependencies: results.filter(dep => dep.isDependency).map(dep => dep.dependentVersion.get('addonName')).sort(),
devDependencies: results.filter(dep => dep.isDevDependency).map(dep => dep.dependentVersion.get('addonName')).sort()
dependencies: results.filter(dependencies).map(dep => dep.dependentVersion.get('addonName')).sort(),
devDependencies: results.filter(devDependencies).map(dep => dep.dependentVersion.get('addonName')).sort()
};
});
}
Expand Down

0 comments on commit 82dbe65

Please sign in to comment.