diff options
| author | Igor Minar | 2011-01-07 22:02:23 -0800 |
|---|---|---|
| committer | Igor Minar | 2011-01-10 10:26:55 -0800 |
| commit | 0a6cf70debc6440685af3f9ea96a66450e4f4ed7 (patch) | |
| tree | 3b7e82bedf53960deb5d460532779ec449dd8dfc /src/Resource.js | |
| parent | c79aba92f6b058742c9ae20a9382f6abc68afcea (diff) | |
| download | angular.js-0a6cf70debc6440685af3f9ea96a66450e4f4ed7.tar.bz2 | |
Rename angular.foreach to angular.forEach to make the api consistent.
camelcase is used for other angular functions and forEach is also
used by EcmaScript standard.
- rename the internal as well as the external function name
- tweak the implementation of the function so that it doesn't
clober it self when we extend the angular object with an
object that has a forEach property equal to this forEach function
Closes #85
Diffstat (limited to 'src/Resource.js')
| -rw-r--r-- | src/Resource.js | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/Resource.js b/src/Resource.js index 570ce1f9..a49dc1c0 100644 --- a/src/Resource.js +++ b/src/Resource.js @@ -4,7 +4,7 @@ function Route(template, defaults) { this.template = template = template + '#'; this.defaults = defaults || {}; var urlParams = this.urlParams = {}; - foreach(template.split(/\W/), function(param){ + forEach(template.split(/\W/), function(param){ if (param && template.match(new RegExp(":" + param + "\\W"))) { urlParams[param] = true; } @@ -17,13 +17,13 @@ Route.prototype = { var self = this; var url = this.template; params = params || {}; - foreach(this.urlParams, function(_, urlParam){ + forEach(this.urlParams, function(_, urlParam){ var value = params[urlParam] || self.defaults[urlParam] || ""; url = url.replace(new RegExp(":" + urlParam + "(\\W)"), value + "$1"); }); url = url.replace(/\/?#$/, ''); var query = []; - foreachSorted(params, function(value, key){ + forEachSorted(params, function(value, key){ if (!self.urlParams[key]) { query.push(encodeURI(key) + '=' + encodeURI(value)); } @@ -52,7 +52,7 @@ ResourceFactory.prototype = { actions = extend({}, ResourceFactory.DEFAULT_ACTIONS, actions); function extractParams(data){ var ids = {}; - foreach(paramDefaults || {}, function(value, key){ + forEach(paramDefaults || {}, function(value, key){ ids[key] = value.charAt && value.charAt(0) == '@' ? getter(data, value.substr(1)) : value; }); return ids; @@ -62,7 +62,7 @@ ResourceFactory.prototype = { copy(value || {}, this); } - foreach(actions, function(action, name){ + forEach(actions, function(action, name){ var isPostOrPut = action.method == 'POST' || action.method == 'PUT'; Resource[name] = function (a1, a2, a3) { var params = {}; @@ -97,7 +97,7 @@ ResourceFactory.prototype = { if (status == 200) { if (action.isArray) { value.length = 0; - foreach(response, function(item){ + forEach(response, function(item){ value.push(new Resource(item)); }); } else { |
