Skip to content

Instantly share code, notes, and snippets.

@noahlt
Created May 11, 2016 17:50
Show Gist options
  • Save noahlt/a03359b333048ba4362adc79b82a3fe2 to your computer and use it in GitHub Desktop.
Save noahlt/a03359b333048ba4362adc79b82a3fe2 to your computer and use it in GitHub Desktop.

A bit easier to read:

var installed = WindowController.getInstalledPlugins();
return {
  installedPlugins: _.intersection(conf.SUPPORTED_EDITORS, installed),
  uninstalledPlugins: _.difference(conf.SUPPORTED_EDITORS, installed),
}

Slightly (negligibly) more efficient:

return _.groupBy(conf.SUPPORTED_EDITORS,
  (e) => _.includes(WindowController.getInstalledPlugins(), e) ? 'installedPlugins' : 'uninstalledPlugins');

I'd probably prefer the former, but wanted to see what it would look like to only iterate through conf.SUPPORTED_EDITORS once.

@mclin
Copy link

mclin commented May 13, 2016

Like the readability of the first one.

I haven't tried them, but I just noticed ES2015 has Sets.

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