Skip to content
This repository has been archived by the owner on Sep 6, 2021. It is now read-only.

Commit

Permalink
Replacing $.each with Array.forEach or CollectionUtils.forEach
Browse files Browse the repository at this point in the history
  • Loading branch information
TomMalbran committed Mar 10, 2013
1 parent 718a006 commit 5878608
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 19 deletions.
2 changes: 1 addition & 1 deletion src/editor/CodeHintList.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ define(function (require, exports, module) {
this.handleClose();
}
} else {
$.each(this.hints, function (index, item) {
this.hints.forEach(function (item, index) {
if (index > self.maxResults) {
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion src/editor/CodeHintManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ define(function (require, exports, module) {
var mode = editor.getModeForSelection(),
enabledProviders = _getProvidersForMode(mode);

$.each(enabledProviders, function (index, item) {
enabledProviders.forEach(function (item, index) {
if (item.provider.hasHints(editor, lastChar)) {
sessionProvider = item.provider;
return false;
Expand Down
4 changes: 2 additions & 2 deletions src/editor/InlineTextEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ define(function (require, exports, module) {
var $dirtyIndicators = $(".inlineEditorHolder .dirty-indicator"),
$indicator;

$.each($dirtyIndicators, function (index, indicator) {
$indicator = $(indicator);
$dirtyIndicators.each(function (index, indicator) {
$indicator = $(this);
if ($indicator.data("fullPath") === doc.file.fullPath) {
_showDirtyIndicator($indicator, doc.isDirty);
}
Expand Down
9 changes: 5 additions & 4 deletions src/preferences/PreferenceStorage.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
define(function (require, exports, module) {
"use strict";

var PreferencesManager = require("preferences/PreferencesManager");
var PreferencesManager = require("preferences/PreferencesManager"),
CollectionUtils = require("utils/CollectionUtils");

/**
* @private
Expand Down Expand Up @@ -144,7 +145,7 @@ define(function (require, exports, module) {
error = null;

// validate all name/value pairs before committing
$.each(obj, function (key, value) {
CollectionUtils.forEach(obj, function (value, key) {
try {
_validateJSONPair(key, value);
} catch (err) {
Expand All @@ -162,13 +163,13 @@ define(function (require, exports, module) {

// delete all exiting properties if not appending
if (!append) {
$.each(this._json, function (key, value) {
CollectionUtils.forEach(this._json, function (value, key) {
delete self._json[key];
});
}

// copy properties from incoming JSON object
$.each(obj, function (key, value) {
CollectionUtils.forEach(obj, function (value, key) {
self._json[key] = value;
});

Expand Down
5 changes: 3 additions & 2 deletions src/project/FileIndexManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ define(function (require, exports, module) {
var PerfUtils = require("utils/PerfUtils"),
ProjectManager = require("project/ProjectManager"),
Dialogs = require("widgets/Dialogs"),
CollectionUtils = require("utils/CollectionUtils"),
Strings = require("strings");

/**
Expand Down Expand Up @@ -134,7 +135,7 @@ define(function (require, exports, module) {
var fileInfo = new FileInfo(entry);
//console.log(entry.name);

$.each(_indexList, function (indexName, index) {
CollectionUtils.forEach(_indexList, function (index, indexName) {
if (index.filterFunction(entry)) {
index.fileInfos.push(fileInfo);
}
Expand Down Expand Up @@ -264,7 +265,7 @@ define(function (require, exports, module) {
* @private
*/
function _clearIndexes() {
$.each(_indexList, function (indexName, index) {
CollectionUtils.forEach(_indexList, function (index, indexName) {
index.fileInfos = [];
});
}
Expand Down
2 changes: 1 addition & 1 deletion src/project/ProjectManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ define(function (require, exports, module) {
node = null;

// use path to lookup ID
$.each(toOpenPaths, function (index, value) {
toOpenPaths.forEach(function (value, index) {
node = _projectInitialLoad.fullPathToIdMap[value];

if (node) {
Expand Down
11 changes: 6 additions & 5 deletions src/strings.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,10 @@
define(function (require, exports, module) {
"use strict";

var strings = require("i18n!nls/strings"),
Global = require("utils/Global"),
StringUtils = require("utils/StringUtils");
var strings = require("i18n!nls/strings"),
Global = require("utils/Global"),
CollectionUtils = require("utils/CollectionUtils"),
StringUtils = require("utils/StringUtils");

var additionalGlobals = {},
parsedVersion = /([0-9]+)\.([0-9]+)\.([0-9]+)/.exec(brackets.metadata.version);
Expand All @@ -52,8 +53,8 @@ define(function (require, exports, module) {
additionalGlobals.BUILD_TYPE = (isDevBuild ? strings.DEVELOPMENT_BUILD : strings.EXPERIMENTAL_BUILD);

// Insert application strings
Object.keys(strings).forEach(function (key) {
Object.keys(additionalGlobals).forEach(function (name) {
CollectionUtils.forEach(strings, function (value, key) {
CollectionUtils.forEach(additionalGlobals, function (item, name) {
strings[key] = strings[key].replace(new RegExp("{" + name + "}", "g"), additionalGlobals[name]);
});
});
Expand Down
5 changes: 3 additions & 2 deletions src/utils/PerfUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
define(function (require, exports, module) {
"use strict";

var Global = require("utils/Global");
var Global = require("utils/Global"),
CollectionUtils = require("utils/CollectionUtils");

/**
* Flag to enable/disable performance data gathering. Default is true (enabled)
Expand Down Expand Up @@ -299,7 +300,7 @@ define(function (require, exports, module) {
var testName,
index,
result = "";
$.each(perfData, function (testName, entry) {
CollectionUtils.forEach(perfData, function (entry, testName) {
result += getValue(entry) + "\t" + testName + "\n";
});

Expand Down
4 changes: 3 additions & 1 deletion src/utils/StringMatch.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
define(function (require, exports, module) {
"use strict";

var CollectionUtils = require("utils/CollectionUtils");

/*
* Performs matching that is useful for QuickOpen and similar searches.
*/
Expand Down Expand Up @@ -715,7 +717,7 @@ define(function (require, exports, module) {
function multiFieldSort(searchResults, fields) {
// Move field names into an array, with primary field first
var fieldNames = [];
$.each(fields, function (key, priority) {
CollectionUtils.forEach(fields, function (priority, key) {
fieldNames[priority] = key;
});

Expand Down

0 comments on commit 5878608

Please sign in to comment.