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

Function forEach

test/angular/1.6/angular.js:405–445  ·  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

403 */
404
405function forEach(obj, iterator, context) {
406 var key, length;
407 if (obj) {
408 if (isFunction(obj)) {
409 for (key in obj) {
410 if (key !== 'prototype' && key !== 'length' && key !== 'name' && obj.hasOwnProperty(key)) {
411 iterator.call(context, obj[key], key, obj);
412 }
413 }
414 } else if (isArray(obj) || isArrayLike(obj)) {
415 var isPrimitive = typeof obj !== 'object';
416 for (key = 0, length = obj.length; key < length; key++) {
417 if (isPrimitive || key in obj) {
418 iterator.call(context, obj[key], key, obj);
419 }
420 }
421 } else if (obj.forEach && obj.forEach !== forEach) {
422 obj.forEach(iterator, context, obj);
423 } else if (isBlankObject(obj)) {
424 // createMap() fast path --- Safe to avoid hasOwnProperty check because prototype chain is empty
425 for (key in obj) {
426 iterator.call(context, obj[key], key, obj);
427 }
428 } else if (typeof obj.hasOwnProperty === 'function') {
429 // Slow path for objects inheriting Object.prototype, hasOwnProperty check needed
430 for (key in obj) {
431 if (obj.hasOwnProperty(key)) {
432 iterator.call(context, obj[key], key, obj);
433 }
434 }
435 } else {
436 // Slow path for objects which do not have a method `hasOwnProperty`
437 for (key in obj) {
438 if (hasOwnProperty.call(obj, key)) {
439 iterator.call(context, obj[key], key, obj);
440 }
441 }
442 }
443 }
444 return obj;
445}
446
447function forEachSorted(obj, iterator, context) {
448 var keys = 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
annotateFunction · 0.70
createInjectorFunction · 0.70

Calls 4

isArrayFunction · 0.85
isFunctionFunction · 0.70
isArrayLikeFunction · 0.70
isBlankObjectFunction · 0.70

Tested by

no test coverage detected