MCPcopy Index your code
hub / github.com/angular-ui/ui-grid / forEach

Function forEach

lib/test/angular/1.6.7/angular.js:395–435  ·  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

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

isFunctionFunction · 0.70
isArrayLikeFunction · 0.70
isBlankObjectFunction · 0.70
isArrayFunction · 0.50

Tested by

no test coverage detected