--- a/backbone.shard.js Thu Jul 05 09:23:39 2018 +0800
+++ b/backbone.shard.js Thu Jul 05 09:23:57 2018 +0800
- * (c) 2013-2017 Anton Shestakov.
+ * (c) 2013-2018 Anton Shestakov.
* This extension to Backbone may be freely distributed
// Underscore methods that we want to implement on the Shard.
- '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'
+ 'all', 'any', 'chain', 'chunk', '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', 'partition', 'reduce', 'reduceRight',
+ 'reject', 'rest', 'sample', 'select', 'shuffle', 'size', 'some', 'tail',
+ 'take', 'toArray', 'without'
// Mix in each Underscore method as a proxy to `Shard#models`.
--- a/test/underscore-methods.js Thu Jul 05 09:23:39 2018 +0800
+++ b/test/underscore-methods.js Thu Jul 05 09:23:57 2018 +0800
return model.get('data').charCodeAt(0) % 2;
}), {0: [b], 1: [a, c]}, 'groupBy() works');
+ deepEqual(shard.partition(function(model) {
+ return model.get('data').charCodeAt(0) % 2;
+ }), [[a, c], [b]], 'partition() works');
+ deepEqual(shard.chunk(1), [[a], [b], [c]], 'chunk() works');
deepEqual(shard.indexBy('data'), {a: a, b: b, c: c}, 'indexBy() works');
var sh = shard.shuffle().reduce(function(memo, model) { return memo += model.get('data'); }, '');