Skip to content
This repository has been archived by the owner on Mar 28, 2019. It is now read-only.

Commit

Permalink
the foreach wrapper works the same way for an array or object
Browse files Browse the repository at this point in the history
  • Loading branch information
touv committed May 21, 2013
1 parent 9dc31a2 commit c04cd57
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/sphinxapi.js
Expand Up @@ -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)
}
}
}
Expand Down Expand Up @@ -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]))
Expand All @@ -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]))
Expand All @@ -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'])]))
Expand Down

0 comments on commit c04cd57

Please sign in to comment.