Skip to content

Commit

Permalink
lint, remove unused deps and files
Browse files Browse the repository at this point in the history
  • Loading branch information
jonschlinkert committed Aug 3, 2015
1 parent 605a641 commit 6a6df19
Show file tree
Hide file tree
Showing 6 changed files with 155 additions and 513 deletions.
48 changes: 5 additions & 43 deletions lib/mixins/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,13 +132,13 @@ module.exports = function (view) {
var items = this.items;
var sorted = sortObj()(this.keyMap, {prop: undefined, get: fn});
var keys = Object.keys(sorted);
var len = keys.length, i = 0;
var len = keys.length, i = -1;
var arr = new Array(len);
while (len--) {

while (++i < len) {
var key = keys[i];
arr[i] = items[sorted[key]];
sorted[key] = i;
i++;
}

this.items = arr;
Expand Down Expand Up @@ -185,46 +185,8 @@ module.exports = function (view) {
* @api public
*/

groupBy: function (prop, fn) {
if (typeof prop === 'function') {
fn = prop;
prop = null;
}
if (typeof fn !== 'function') {
fn = function (value) {
return value;
};
}

var Parent = this.constructor;
var opts = clone()(this.options);
var keys = Object.keys(this.keyMap);
var items = this.items.map(function (item, i) {
item.key = keys[i];
return item;
});

// create a new list of lists
// var groupsList = {}; //new Parent(extend({}, opts, {Item: Parent}));

var grouper = function (acc, item, idx, arr, setter) {
var groups = fn(get()(item, prop) || item);
groups = utils.arrayify(groups);
var len = groups.length, i = -1;
while (++i < len) {
setter(acc, groups[i], item, idx, arr);
}
};

var setter = function (acc, group, item) {
if (typeof group === 'undefined') return;
// var list = acc.item(group) || new Parent(opts);
var list = acc[group] || new Parent(opts);
list.item(item.key, item);
acc[group] = list;
}.bind(this);

return groupBy()(items, grouper, setter, {});
groupBy: function () {
return groupBy()(this.items, [].slice.call(arguments));
},

/**
Expand Down
Loading

0 comments on commit 6a6df19

Please # to comment.