MCPcopy Create free account
hub / github.com/OpenReservation/OpenReservation / forEach

Function forEach

OpenReservation/wwwroot/Scripts/angular.js:307–352  ·  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

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

Calls 3

isFunctionFunction · 0.85
isArrayLikeFunction · 0.85
isBlankObjectFunction · 0.85

Tested by

no test coverage detected