MCPcopy
hub / github.com/angular-ui/ui-router / forEach

Function forEach

test/angular/1.3/angular.js:311–340  ·  view source on GitHub ↗

* @ngdoc function * @name angular.forEach * @module ng * @kind function * * @description * Invokes the `iterator` function once for each item in `obj` collection, which can be either an * object or an array. The `iterator` function is invoked with `iterator(value, key, obj)`, where `value` *

(obj, iterator, context)

Source from the content-addressed store, hash-verified

309 */
310
311function forEach(obj, iterator, context) {
312 var key, length;
313 if (obj) {
314 if (isFunction(obj)) {
315 for (key in obj) {
316 // Need to check if hasOwnProperty exists,
317 // as on IE8 the result of querySelectorAll is an object without a hasOwnProperty function
318 if (key != 'prototype' && key != 'length' && key != 'name' && (!obj.hasOwnProperty || obj.hasOwnProperty(key))) {
319 iterator.call(context, obj[key], key, obj);
320 }
321 }
322 } else if (isArray(obj) || isArrayLike(obj)) {
323 var isPrimitive = typeof obj !== 'object';
324 for (key = 0, length = obj.length; key < length; key++) {
325 if (isPrimitive || key in obj) {
326 iterator.call(context, obj[key], key, obj);
327 }
328 }
329 } else if (obj.forEach && obj.forEach !== forEach) {
330 obj.forEach(iterator, context, obj);
331 } else {
332 for (key in obj) {
333 if (obj.hasOwnProperty(key)) {
334 iterator.call(context, obj[key], key, obj);
335 }
336 }
337 }
338 }
339 return obj;
340}
341
342function sortedKeys(obj) {
343 return Object.keys(obj).sort();

Callers 15

copyFunction · 0.70
parseKeyValueFunction · 0.70
toKeyValueFunction · 0.70
angularInitFunction · 0.70
bootstrapFunction · 0.70
jqLiteBuildFragmentFunction · 0.70
jqLiteOffFunction · 0.70
jqLiteRemoveClassFunction · 0.70
jqLiteAddClassFunction · 0.70
angular.jsFile · 0.70
HashMapFunction · 0.70
annotateFunction · 0.70

Calls 3

isArrayFunction · 0.85
isFunctionFunction · 0.70
isArrayLikeFunction · 0.70

Tested by

no test coverage detected