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

Function forEach

lib/test/angular/1.8.0/angular.js:375–415  ·  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

373 */
374
375function forEach(obj, iterator, context) {
376 var key, length;
377 if (obj) {
378 if (isFunction(obj)) {
379 for (key in obj) {
380 if (key !== 'prototype' && key !== 'length' && key !== 'name' && obj.hasOwnProperty(key)) {
381 iterator.call(context, obj[key], key, obj);
382 }
383 }
384 } else if (isArray(obj) || isArrayLike(obj)) {
385 var isPrimitive = typeof obj !== 'object';
386 for (key = 0, length = obj.length; key < length; key++) {
387 if (isPrimitive || key in obj) {
388 iterator.call(context, obj[key], key, obj);
389 }
390 }
391 } else if (obj.forEach && obj.forEach !== forEach) {
392 obj.forEach(iterator, context, obj);
393 } else if (isBlankObject(obj)) {
394 // createMap() fast path --- Safe to avoid hasOwnProperty check because prototype chain is empty
395 for (key in obj) {
396 iterator.call(context, obj[key], key, obj);
397 }
398 } else if (typeof obj.hasOwnProperty === 'function') {
399 // Slow path for objects inheriting Object.prototype, hasOwnProperty check needed
400 for (key in obj) {
401 if (obj.hasOwnProperty(key)) {
402 iterator.call(context, obj[key], key, obj);
403 }
404 }
405 } else {
406 // Slow path for objects which do not have a method `hasOwnProperty`
407 for (key in obj) {
408 if (hasOwnProperty.call(obj, key)) {
409 iterator.call(context, obj[key], key, obj);
410 }
411 }
412 }
413 }
414 return obj;
415}
416
417function forEachSorted(obj, iterator, context) {
418 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
isArrayFunction · 0.70
isArrayLikeFunction · 0.70
isBlankObjectFunction · 0.70

Tested by

no test coverage detected