-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(common): fixed the _.filter clone to not create sparse arrays
Closes #1563
- Loading branch information
1 parent
e9f8b8a
commit 750f5cf
Showing
2 changed files
with
20 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
describe('_-like filter', function() { | ||
it("should filter arrays", function() { | ||
var input = [ 1, 2, 3, 4, 5 ]; | ||
var filtered = filter(input, function(int) { return int > 2; }); | ||
expect(filtered.length).toBe(3); | ||
expect(filtered).toEqual([ 3, 4, 5 ]); | ||
}); | ||
|
||
it("should filter objects", function() { | ||
var input = { foo: 1, bar: 2, baz: 3, qux: 4 }; | ||
var filtered = filter(input, function(val, key) { return val > 2; }); | ||
expect(Object.keys(filtered).length).toBe(2); | ||
expect(filtered).toEqual({ baz: 3, qux: 4 }); | ||
}); | ||
}); |