https://github.com/yornaath/filter
Filter collections, arrays and objects.
https://github.com/yornaath/filter
Last synced: 7 months ago
JSON representation
Filter collections, arrays and objects.
- Host: GitHub
- URL: https://github.com/yornaath/filter
- Owner: yornaath
- Created: 2012-10-30T09:03:56.000Z (almost 13 years ago)
- Default Branch: master
- Last Pushed: 2012-10-30T09:37:25.000Z (almost 13 years ago)
- Last Synced: 2025-01-22T07:35:54.200Z (9 months ago)
- Size: 141 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: Readme.md
Awesome Lists containing this project
README
# filter
Filtering arrays or objects.
## Installation
$ component install gorillatron/filter
## Usage
```javascript
var numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ]
function even( n ) { return n % 2 === 0 }
filter( numbers, even )
//-> [ 2, 4, 6, 8, 10 ]```
### API
#### filter( collection, fn, context )
Collection can be either array or object. Fn will be run for each value in the collection and if it returns true
the value will be put in the returned array. The context parameter will be used to bind the this value of the fn.
## License
MIT