harthur/js-select — pull request #2 by brianreavis (2012-09-17 17:36:36+00:00)
Title: Added condense() method for reducing objects down to matching elements.

Hey! First off, js-select is awesome!

I added a method that will reduce an object down to only the elements that match the selector (while preserving the hierarchy). For example:

```javascript
var things = [
{name: "Nikola Tesla", awesomeness: 99},
{name: "NASA", people: [
{name: "Buzz Aldrin", awesomeness: 50},
{name: "Neil Armstrong", awesomeness: 50}
]}
];

select(things, ".awesomeness").condense();
```

This will squash `things` down to:
```javascript
[
{awesomeness: 99},
{people: [
{awesomeness: 50},
{awesomeness: 50}
]}
]
```

We're using it on the API at [DIY](https://diy.org) to allow filtering of the output (to make responses as small as they can be). Ish:

/projects/1?filter=.images%20.small