MCPcopy
hub / github.com/Postcatlab/postcat / forEach

Function forEach

src/workbench/browser/src/ng1/lib/angular/angular.js:406–446  ·  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,

(obj, iterator, context)

Source from the content-addressed store, hash-verified

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

Callers 15

copyFunction · 0.85
parseKeyValueFunction · 0.85
toKeyValueFunction · 0.85
angularInitFunction · 0.85
bootstrapFunction · 0.85
jqLiteBuildFragmentFunction · 0.85
jqLiteOffFunction · 0.85
jqLiteRemoveClassFunction · 0.85
jqLiteAddClassFunction · 0.85
angular.jsFile · 0.85
annotateFunction · 0.85
createInjectorFunction · 0.85

Calls 5

isFunctionFunction · 0.85
isArrayFunction · 0.85
isArrayLikeFunction · 0.85
isBlankObjectFunction · 0.85
callMethod · 0.80

Tested by

no test coverage detected