Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

List dependents of a package. #11

merged 1 commit into from Nov 11, 2012


None yet
2 participants

timoxley commented Nov 11, 2012

It's useful to see what depends on a particular package:

  • Aids in component discovery.
  • Gives clues at to which components are considered canonical.
  • …which in turn should help prevent components with duplicate functionality popping up.
  • Shows practical 'usage examples'.
  • Shows where work needs to be done (e.g. number of dependents on jquery).

Whether/how you want to add this to the human readable component-search output is up to you, this will at least make it available in the --json output, but perhaps a flag like --show-dependents and/or some kind of limit on the number of dependents in default output, e.g.

  url: https://github.com/component/jquery
  desc: jQuery component
  dependents: btknorr/davis.js, component/progress-notification, component/calendar + 25 others
  ★ 1


(Manually omitted package details other than name and dependents)

  "name": "notification",
  "dependents": [ // 2
  "name": "stream",
  "dependents": [ // 6
  "name": "jquery",
  "dependents": [ // 28
  "name": "classes",
  "dependents": [ // 14
// ETC

@tj tj commented on the diff Nov 11, 2012

+ * @param pkg
+ * @param pkgs {Array} All packages to analyse.
+ * @return {Array} Repos of packages that depend on `pkg`.
+ */
+function dependents(pkg, pkgs) {
+ var repo = pkg.repo
+ return pkgs.filter(blank).filter(function(pkg) {
+ pkg.dependencies = pkg.dependencies || []
+ return Object.keys(pkg.dependencies).indexOf(repo) !== -1
+ }).map(function(pkg) {
+ return pkg.repo
+ })
+function blank(pkg) {
+ return !!pkg

tj Nov 11, 2012


hehe :D I still need to find the source of these damn blanks


tj commented Nov 11, 2012

great idea ! thanks man, this will aid in building a dependency graph as well, I definitely want that on the site

@tj tj added a commit that referenced this pull request Nov 11, 2012

@tj tj Merge pull request #11 from timoxley/feature/list-dependents
List dependents of a package.

@tj tj merged commit 5c05716 into componentjs:master Nov 11, 2012


timoxley commented Nov 24, 2012

Bump… keen to see this one go live.


tj commented Nov 24, 2012

I do think we should map these but I think I'll make it optional in the search response since it causes a lot of JSON bloat

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment