The Enumerable mixin class does not properly respect the mixees internal format.
So the reject and findAll methods, used with Hashes return Arrays instead of
Hashes.
In Ruby (from which the inspiration for the Enumerable Mixin stems), the reject method sure does return a hash, not an array, when acting on an hash:
irb(main):001:0> a = {:a => 1, :b => 2, :c => 1, :d => 3}
=> {:b=>2, :c=>1, :a=>1, :d=>3}
irb(main):002:0> b = a.reject{|k,v| v==1}
=> {:b=>2, :d=>3}
The patch requires all classes that want to mixin Enumerable to define two more methods similar to _each: _new, which return s an empty object of that class and _add, that adds an element. The Enumerable thus makes no more assumptions about the internal structure of its mixee class.
Examples (before and after fix) are given below.
var a = $H({a:1, b:2, c:1, d:3});
document.writeln(a.inspect().escapeHTML());
=> #<Hash:{'a': 1, 'b': 2, 'c': 1, 'd': 3}>
var b = a.reject(function(val){ return (val[1]==1) });
document.writeln(b.inspect().escapeHTML());
1.4.0 => [['b', 2], ['d', 3]]
patched => #<Hash:{'b': 2, 'd': 3}>
var c = b.findAll(function(val){ return (val[0]=='d') });
document.writeln(c.inspect().escapeHTML());
1.4.0 => [['b', 2], ['d', 3]]
patched => #<Hash:{'d': 3}>