Skip to content

Commit

Permalink
Replace 'for in' with 'Object.keys'
Browse files Browse the repository at this point in the history
  • Loading branch information
neumino committed Jul 6, 2014
1 parent 6cd4ca1 commit 79d5b6d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
5 changes: 3 additions & 2 deletions lib/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,9 @@ function hasImplicit(arg) {
module.exports.hasImplicit = hasImplicit;

function loopKeys(obj, fn) {
for(var key in obj) {
fn(obj, key);
var keys = Object.keys(obj);
for(var i=0; i<keys.length; i++) {
fn(obj, keys[i]);
}
}
module.exports.loopKeys = loopKeys;
Expand Down
12 changes: 4 additions & 8 deletions lib/term.js
Original file line number Diff line number Diff line change
Expand Up @@ -1635,10 +1635,8 @@ Term.prototype.expr = function(expression, nestingLevel) {

var optArgs = {};
helper.loopKeys(expression, function(expression, key) {
if (expression.hasOwnProperty(key)) {
if (expression[key] !== undefined) {
optArgs[key] = new Term(self._r).expr(expression[key], nestingLevel-1)._query;
}
if (expression[key] !== undefined) {
optArgs[key] = new Term(self._r).expr(expression[key], nestingLevel-1)._query;
}
});
return new Term(self._r, optArgs);
Expand Down Expand Up @@ -1772,10 +1770,8 @@ Term.prototype._translateArgs = {
function translateOptions(options) {
var translatedOpt = {};
helper.loopKeys(options, function(options, key) {
if (options.hasOwnProperty(key) && (options[key] !== undefined)) {
var keyServer = Term.prototype._translateArgs[key] || key;
translatedOpt[keyServer] = options[key];
}
var keyServer = Term.prototype._translateArgs[key] || key;
translatedOpt[keyServer] = options[key];
});
return translatedOpt;
}
Expand Down

0 comments on commit 79d5b6d

Please sign in to comment.