|
8 | 8 | test = {}, |
9 | 9 | scopes = 0; |
10 | 10 |
|
11 | | - // go through each element. Count watchers if it has scope or isolate scope |
12 | | - for (i=0; i < len; i++) { |
13 | | - /* global angular */ |
14 | | - data = angular.element(all[i]).data(); |
15 | | - scope = data.$scope || data.$isolateScope; |
16 | | - if (scope) { |
17 | | - if ( ! test[ scope.$id ] ) { |
18 | | - test[ scope.$id ] = true; |
19 | | - count += sizeof(scope); |
20 | | - scopes += 1; |
21 | | - } |
22 | | - } |
23 | | - } |
24 | | - console.log(scopes, 'scopes have', count, 'bytes attached'); |
25 | | - return count; |
26 | | - |
27 | 11 | /* |
28 | 12 | sizeof.js modified for angular scope client data computation |
29 | 13 | A function to calculate the approximate memory usage of objects |
|
41 | 25 |
|
42 | 26 | // initialise the list of objects and size |
43 | 27 | var objects = [object]; |
44 | | - var size = 0; |
| 28 | + var size = 0; |
45 | 29 |
|
46 | 30 | // loop over the objects |
47 | | - for (var index = 0; index < objects.length; index ++){ |
| 31 | + for (var index = 0; index < objects.length; index += 1) { |
48 | 32 |
|
49 | 33 | // determine the type of the object |
50 | 34 | switch (typeof objects[index]) { |
|
73 | 57 | // determine whether the value has already been processed |
74 | 58 | var processed = false; |
75 | 59 | /* jshint -W073 */ |
76 | | - for (var search = 0; search < objects.length; search ++){ |
| 60 | + for (var search = 0; search < objects.length; search += 1){ |
77 | 61 | if (objects[search] === objects[index][key]){ |
78 | 62 | processed = true; |
79 | 63 | break; |
|
96 | 80 |
|
97 | 81 | } |
98 | 82 |
|
| 83 | + // go through each element. Count watchers if it has scope or isolate scope |
| 84 | + /* eslint no-for-loops:0 */ |
| 85 | + for (i = 0; i < len; i++) { |
| 86 | + /* global angular */ |
| 87 | + data = angular.element(all[i]).data(); |
| 88 | + scope = data.$scope || data.$isolateScope; |
| 89 | + if (scope) { |
| 90 | + if ( !test[ scope.$id ] ) { |
| 91 | + test[ scope.$id ] = true; |
| 92 | + count += sizeof(scope); |
| 93 | + scopes += 1; |
| 94 | + } |
| 95 | + } |
| 96 | + } |
| 97 | + console.log(scopes, 'scopes have', count, 'bytes attached'); |
| 98 | + return count; |
| 99 | + |
99 | 100 | }()); |
0 commit comments