| 49 | |
| 50 | // transforms [1,"a","A","B"] to [{a:"A"},{a:"B"}] |
| 51 | function hunpack(hlist) { |
| 52 | for (var |
| 53 | length = hlist.length, |
| 54 | klength = hlist[0], |
| 55 | result = Array(((length - klength - 1) / klength) || 0), |
| 56 | i = 1 + klength, |
| 57 | j = 0, |
| 58 | ki, o; |
| 59 | i < length; |
| 60 | ) { |
| 61 | for ( |
| 62 | result[j++] = (o = {}), ki = 0; |
| 63 | ki < klength; |
| 64 | o[hlist[++ki]] = hlist[i++] |
| 65 | ); |
| 66 | } |
| 67 | return result; |
| 68 | } |
| 69 | |
| 70 | // recursive: called via map per each item h(pack|unpack)ing each entry through the schema |
| 71 | function iteratingWith(method) { |