Skip to content

Instantly share code, notes, and snippets.

@apaleslimghost
Last active July 18, 2016 20:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save apaleslimghost/33cfaffd6043951e8fd087b683e08582 to your computer and use it in GitHub Desktop.
Save apaleslimghost/33cfaffd6043951e8fd087b683e08582 to your computer and use it in GitHub Desktop.
var count = require('lodash.countby');
var sum = require('lodash.sum');
var filter = require('lodash.filter');
var size = require('lodash.size');
var values = require('lodash.values');
var pairs = require('lodash.pairs');
var head = require('lodash.head');
var assign = require('lodash.assign');
var mapToObject = require('@quarterto/map-to-object');
module.exports = (xs, ensure = []) => {
const zeroes = mapToObject(ensure, () => 0);
const c = assign(zeroes, count(xs));
const μ = sum(values(c))/size(c);
return filter(pairs(c), (v) => v[1] <= μ).map(head);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment