mbostock/d3 — pull request #1523 by herrstucki (2013-09-12 20:53:20+00:00)
Title: d3.index

A tiny function for indexing arrays, e.g.

```javascript
d3.index([{foo: "a"}, {foo: "b"}], function(d) { return d.foo; });
// => {a: {foo: "a"}, b: {foo: "b"}}
```

It doesn't do much but I run into the need for this quite regularly and it's slightly more convenient than looping manually. Of course `d3.nest` can be used but it feels kind of verbose.

```javascript
d3.nest()
.key(function(d) { return d.foo; })
.rollup(function(values) { return values[0]; })
.map([{foo: "a"}, {foo: "b"}]);
```

*PS: Not sure about the file name, as index.js is already taken*