--- a/static/js/backbone.shard.js Mon Jun 27 18:13:01 2016 +0800
+++ b/static/js/backbone.shard.js Thu Jun 30 21:47:54 2016 +0800
- * (c) 2013 Anton Shestakov.
+ * (c) 2013, 2016 Anton Shestakov.
* This extension to Backbone may be freely distributed
- * http://opensource.org/licenses/mit-license.php
+ * https://opensource.org/licenses/MIT
Backbone.Shard = function(options) {
this._collection = options.collection;
this._filter = options.filter;
this.models = this._collection.filter(this._filter);
.on('all', function(event, model) {
this.models = this._collection.filter(this._filter);
this.initialize.apply(this, arguments);
_.extend(Backbone.Shard.prototype, Backbone.Events, {
initialize: function() {},
return _.map(this.models, function(model) { return model.get(attr); });
// Underscore methods that we want to implement on the Shard.
-var methods = ['forEach', 'each', 'map', 'collect', 'reduce', 'foldl',
- 'inject', 'reduceRight', 'foldr', 'find', 'detect', 'filter', 'select',
- 'reject', 'every', 'all', 'some', 'any', 'include', 'contains', 'invoke',
- 'max', 'min', 'toArray', 'size', 'first', 'head', 'take', 'initial', 'rest',
- 'tail', 'drop', 'last', 'without', 'indexOf', 'shuffle', 'lastIndexOf',
+ 'all', 'any', 'chain', 'collect', 'contains', 'detect', 'difference',
+ 'drop', 'each', 'every', 'filter', 'find', 'findIndex', 'findLastIndex',
+ 'first', 'foldl', 'foldr', 'forEach', 'head', 'include', 'includes',
+ 'indexOf', 'initial', 'inject', 'invoke', 'isEmpty', 'last', 'lastIndexOf',
+ 'map', 'max', 'min', 'reduce', 'reduceRight', 'reject', 'rest', 'sample',
+ 'select', 'shuffle', 'size', 'some', 'tail', 'take', 'toArray', 'without'
// Mix in each Underscore method as a proxy to `Shard#models`.
_.each(methods, function(method) {
// Underscore methods that take a property name as an argument.
-var attributeMethods = ['groupBy', 'countBy', 'sortBy'];
+var attributeMethods = ['countBy', 'groupBy', 'indexBy', 'sortBy'];
// Use attributes instead of properties.
_.each(attributeMethods, function(method) {