Permalink
Browse files

remove ctx from filter

  • Loading branch information...
1 parent 49e02fe commit 0e397e4b65e76270331f28336bf762a32dd63365 @marcuswestin committed May 30, 2013
Showing with 4 additions and 10 deletions.
  1. +4 −10 filter.js
View
@@ -6,27 +6,21 @@
var each = require('./each')
var isArray = require('./isArray')
-module.exports = function filter(arr, ctx, fn) {
+module.exports = function filter(arr, fn) {
if (!arr) { return [] }
- if (arguments.length == 2) {
- fn = ctx
- ctx = this
- }
- if (!fn) {
- fn = falseOrTruthy
- }
+ if (!fn) { fn = falseOrTruthy }
var result
if (isArray(arr)) {
result = []
each(arr, function(value, index) {
- if (!fn.call(ctx, value, index)) { return }
+ if (!fn(value, index)) { return }
result.push(value)
})
} else {
result = {}
each(arr, function(value, key) {
- if (!fn.call(ctx, value, key)) { return }
+ if (!fn(value, index)) { return }
result[key] = value
})
}

0 comments on commit 0e397e4

Please sign in to comment.