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

Function forEach

lib/test/angular/1.4.3/angular.js:321–363  ·  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

319 */
320
321function forEach(obj, iterator, context) {
322 var key, length;
323 if (obj) {
324 if (isFunction(obj)) {
325 for (key in obj) {
326 // Need to check if hasOwnProperty exists,
327 // as on IE8 the result of querySelectorAll is an object without a hasOwnProperty function
328 if (key != 'prototype' && key != 'length' && key != 'name' && (!obj.hasOwnProperty || obj.hasOwnProperty(key))) {
329 iterator.call(context, obj[key], key, obj);
330 }
331 }
332 } else if (isArray(obj) || isArrayLike(obj)) {
333 var isPrimitive = typeof obj !== 'object';
334 for (key = 0, length = obj.length; key < length; key++) {
335 if (isPrimitive || key in obj) {
336 iterator.call(context, obj[key], key, obj);
337 }
338 }
339 } else if (obj.forEach && obj.forEach !== forEach) {
340 obj.forEach(iterator, context, obj);
341 } else if (isBlankObject(obj)) {
342 // createMap() fast path --- Safe to avoid hasOwnProperty check because prototype chain is empty
343 for (key in obj) {
344 iterator.call(context, obj[key], key, obj);
345 }
346 } else if (typeof obj.hasOwnProperty === 'function') {
347 // Slow path for objects inheriting Object.prototype, hasOwnProperty check needed
348 for (key in obj) {
349 if (obj.hasOwnProperty(key)) {
350 iterator.call(context, obj[key], key, obj);
351 }
352 }
353 } else {
354 // Slow path for objects which do not have a method `hasOwnProperty`
355 for (key in obj) {
356 if (hasOwnProperty.call(obj, key)) {
357 iterator.call(context, obj[key], key, obj);
358 }
359 }
360 }
361 }
362 return obj;
363}
364
365function forEachSorted(obj, iterator, context) {
366 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
HashMapFunction · 0.70
annotateFunction · 0.70

Calls 4

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

Tested by

no test coverage detected