MCPcopy Create free account
hub / github.com/WebReflection/JSONH / hunpack

Function hunpack

js/jsonh.js:51–68  ·  view source on GitHub ↗
(hlist)

Source from the content-addressed store, hash-verified

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) {

Callers 1

unpackFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected