Permalink
Browse files

corrected filter on objects

  • Loading branch information...
1 parent dd07638 commit 8500e25c2f33b8eac1ea7fe979693e999847973c @dominictarr committed Nov 30, 2011
Showing with 2 additions and 4 deletions.
  1. +2 −4 objects.js
View
@@ -113,17 +113,15 @@ var findKey = exports.findKey = function (obj, iterator) {
var filter = exports.filter = function (obj, iterator){
iterator = rx (iterator)
- if(Array.isArray(obj))
- return obj.filter(iterator)
if(Array.isArray(obj))
return obj.filter(iterator)
var keys = Object.keys(obj)
, r = {}
keys.forEach(function (key){
- var v = iterator(obj[key],key,obj)
- if(v)
+ var v
+ if(iterator(v = obj[key],key,obj))
r[key] = v
})
return r

0 comments on commit 8500e25

Please sign in to comment.