Skip to content
This repository has been archived by the owner on Jun 24, 2018. It is now read-only.

Commit

Permalink
add thisObject to partitionBy
Browse files Browse the repository at this point in the history
  • Loading branch information
osteele committed Apr 21, 2008
1 parent b1a67c4 commit 6b2d5b2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
6 changes: 6 additions & 0 deletions Rakefile
@@ -0,0 +1,6 @@
require 'rake/rdoctask'

Rake::RDocTask.new do |rd|
rd.main = "README"
rd.rdoc_files.include("README", "CHANGES")
end
4 changes: 2 additions & 2 deletions lib/collections.js
Expand Up @@ -205,11 +205,11 @@ define(Array, 'last', function() {
* return value is a hash, where the keys are the values returned by
* `fn` and the values are lists of elements with those keys.
*/
define(Array, 'partitionBy', function(fn) {
define(Array, 'partitionBy', function(fn, thisObject) {
var partitions = {};
for (var i = 0, len = this.length; i < len; i++) {
var item = this[i],
key = fn(item, i),
key = fn.call(thisObject, item, i),
partition = partitions[key];
if (!partition)
partition = partitions[key] = [];
Expand Down

0 comments on commit 6b2d5b2

Please sign in to comment.