function sift(query, array, getter) { if (isFunction(array)) { getter = array; array = void 0; } var validator = createRootValidator(query, getter); function filter(b) { return validate(validator, b); } if (array) { return array.filter(filter); } return filter; }
...
<body>
</body>
</html>
```
## API
### .sift(filter[, array][, selectorFn])
- `filter` - the filter to use against the target array
- `array` - sifts against target array. Without this, a function is returned
- `selectorFn` - selector for the values within the array.
With an array:
...
compare = function (a, b) { if(a===b) return 0; if(typeof a === typeof b) { if (a > b) { return 1; } if (a < b) { return -1; } } }
n/a
indexOf = function (query, array, getter) { return search(array, createRootValidator(query, getter)); }
...
{
name: 'tim',
address: {
city: 'St. Paul'
}
}];
var index = sift.indexOf({ address: { city: 'Minneapolis' }}, people); // index
= 0
```
...
use = function (plugin) { if (isFunction(plugin)) return plugin(sift); for (var key in plugin) { if (key.charCodeAt(0) === 36) { operator[key] = plugin[key]; } } }
...
## Custom Expressions
You can add your own expressions. For instance - say you want to do some bitmask filtering, you could add this example:
```javascript
sift.use({
$band: function(a, b) {
return (a & b) ? 0 : -1; // 0 = exists, -1 = doesn't exist
}
});
// ops
var IS_ANIMAL = 2,
...