(map, depth)
| 276 | return object; |
| 277 | } |
| 278 | function entries(map, depth) { |
| 279 | if (depth >= keys.length) return map; |
| 280 | var array = [], sortKey = sortKeys[depth++]; |
| 281 | map.forEach(function(key, keyMap) { |
| 282 | array.push({ |
| 283 | key: key, |
| 284 | values: entries(keyMap, depth) |
| 285 | }); |
| 286 | }); |
| 287 | return sortKey ? array.sort(function(a, b) { |
| 288 | return sortKey(a.key, b.key); |
| 289 | }) : array; |
| 290 | } |
| 291 | nest.map = function(array, mapType) { |
| 292 | return map(mapType, array, 0); |
| 293 | }; |