<commit_before>![Alt travis status](https://secure.travis-ci.org/crcn/sift.js.png)


## Features:

- supported operators: $in, $nin, $exists, $gte, $gt, $lte, $lt, $eq, $neq, $mod, $all, $and, $or, $size, $type
- Regexp searches
- Function filtering
- Deep object searching

## Simple Examples

```javascript

var sift = require('sift');

//interesecting arrays
var sifted = sift({ $in: ['hello','world'] }, ['hello','sifted','array!']); //['hello']

//regexp filter
var sifted = sift(/^j/, ['craig','john','jake']); //['john','jake']

//function filter
var siftPeople = sift({
	name: function(value) {
		return name.length == 5;
	}
});

//filtered: [{ name: 'craig' }]
siftPeople([{
	name: 'craig',
},
{
	name: 'john'
},
{
	name: 'jake'
}]);

```

## API

### .sift(filter[, array])

- `filter` - the filter to use against the target array
- `array` - sifts against target array. Without this, a function is returned

With an array:

```javascript
sift({$exists:true}, ['craig',null]); //['craig']
```

Without an array:

```javascript
var siftExists = sift({$exists:true});

siftExists(['craig',null]); //['craig']
```


## Supported Operators:

See MonboDB's [advanced queries](http://www.mongodb.org/display/DOCS/Advanced+Queries) for more info.

### $in

array value must be *$in* the given query:

Intersecting two arrays:
 
```javascript
//filtered: ['Brazil']<commit_msg>added docs for testing values<commit_after>![Alt travis status](https://secure.travis-ci.org/crcn/sift.js.png)


## Features:

- supported operators: $in, $nin, $exists, $gte, $gt, $lte, $lt, $eq, $neq, $mod, $all, $and, $or, $size, $type
- Regexp searches
- Function filtering
- Deep object searching

## Simple Examples

```javascript

var sift = require('sift');

//interesecting arrays
var sifted = sift({ $in: ['hello','world'] }, ['hello','sifted','array!']); //['hello']

//regexp filter
var sifted = sift(/^j/, ['craig','john','jake']); //['john','jake']

//function filter
var siftPeople = sift({
	name: function(value) {
		return name.length == 5;
	}
});

//filtered: [{ name: 'craig' }]
siftPeople([{
	name: 'craig',
},
{
	name: 'john'
},
{
	name: 'jake'
}]);

```

## API

### .sift(filter[, array])

- `filter` - the filter to use against the target array
- `array` - sifts against target array. Without this, a function is returned

With an array:

```javascript
sift({$exists:true}, ['craig',null]); //['craig']
```

Without an array, a sifter is returned:

```javascript
var siftExists = sift({$exists:true});

siftExists(['craig',null]); //['craig']
```

With your sifter, you can also **test** values:

```javascript
siftExists.test(null); //false
siftExists.test('craig'); //true
```


## Supported Operators:

See MonboDB's [advanced queries](http://www.mongodb.org/display/DOCS/Advanced+Queries) for more info.

### $in

array value must be *$in* the given query:

Intersecting two arrays:
 
```javascript
//filtered: ['Brazil']
{'fraction_non_alphanumeric': 0.2114071038251366, 'fraction_numerical': 0.0006830601092896175, 'mean_word_length': 4.557874762808349, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1283629', 'n_tokens_mistral': 1125, 'n_tokens_neox': 1056, 'n_words': 286}