diff --git a/lib/sphinxapi.js b/lib/sphinxapi.js index f8893a4..f5c00e8 100644 --- a/lib/sphinxapi.js +++ b/lib/sphinxapi.js @@ -61,7 +61,7 @@ function forEach(o, fn) { else { for (var key in o) { if (o.hasOwnProperty(key)) { - fn(key, o[key]) + fn(o[key], key) } } } @@ -583,7 +583,7 @@ SphinxClient.prototype.AddQuery = function (query, index, comment) { // per-index weights req.push(pack('>L', [len(self._indexweights)])) - forEach(self._indexweights, function (index, weight) { + forEach(self._indexweights, function (weight, index) { req.push(pack('>L', [len(index)])) req.push(index) req.push(pack('>L', [weight])) @@ -594,7 +594,7 @@ SphinxClient.prototype.AddQuery = function (query, index, comment) { // per-field weights req.push(pack('>L', [len(self._fieldweights)])) - forEach(self._fieldweights, function (field, weight) { + forEach(self._fieldweights, function (weight, field) { req.push(pb.pack('>L', [len(field)])) req.push(field) req.push(pack('>L', [weight])) @@ -607,7 +607,7 @@ SphinxClient.prototype.AddQuery = function (query, index, comment) { // attribute overrides req.push(pack('>L', [len(self._overrides)])) - forEach(self._overrides, function (index, v) { + forEach(self._overrides, function (v, index) { req.push(pack('>L', [len(v['name'])])) req.push(v['name']) req.push(pack('>LL', [v['type'], len(v['values'])]))