Skip to content

Commit f35bc00

Browse files
committed
fixed jscs
1 parent fadba54 commit f35bc00

File tree

4 files changed

+66
-61
lines changed

4 files changed

+66
-61
lines changed

local-storage-size.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// based on answer to question
22
// http://stackoverflow.com/questions/4391575/how-to-find-the-size-of-localstorage
3-
(function showLocalStorageSize(){
3+
(function showLocalStorageSize() {
44
function stringSizeBytes(str) {
55
return str.length * 2;
66
}

ng-count-watchers.js

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
// taken from http://ng.malsup.com/#!/counting-watchers
22
(function countAngularWatchers() {
3-
var i, data, scope,
4-
count = 0,
5-
all = document.all,
6-
len = all.length,
7-
test = {};
3+
var i, data, scope,
4+
count = 0,
5+
all = document.all,
6+
len = all.length,
7+
test = {};
88

9-
// go through each element. Count watchers if it has scope or isolate scope
10-
/* eslint no-for-loops:0 */
11-
for (i = 0; i < len; i++) {
12-
/* global angular */
13-
data = angular.element(all[i]).data();
14-
scope = data.$scope || data.$isolateScope;
15-
if (scope && scope.$$watchers) {
16-
if ( !test[ scope.$id ] ) {
17-
test[ scope.$id ] = true;
18-
count += scope.$$watchers.length;
19-
}
20-
}
9+
// go through each element. Count watchers if it has scope or isolate scope
10+
/* eslint no-for-loops:0 */
11+
for (i = 0; i < len; i++) {
12+
/* global angular */
13+
data = angular.element(all[i]).data();
14+
scope = data.$scope || data.$isolateScope;
15+
if (scope && scope.$$watchers) {
16+
if ( !test[ scope.$id ] ) {
17+
test[ scope.$id ] = true;
18+
count += scope.$$watchers.length;
19+
}
2120
}
22-
console.log('this page has', count, 'angular watchers');
23-
return count;
21+
}
22+
console.log('this page has', count, 'angular watchers');
23+
return count;
2424
})();

ng-find-scope-property.js

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,32 @@
11
// finds all properties with given name attached to the scopes
22
(function (window) {
33

4-
function findScopeProperty(name) {
5-
var i, data, scope,
6-
all = document.all,
7-
len = all.length,
8-
test = {};
9-
var found = [];
4+
function findScopeProperty(name) {
5+
var i, data, scope,
6+
all = document.all,
7+
len = all.length,
8+
test = {};
9+
var found = [];
1010

11-
/* global angular */
12-
/* eslint no-for-loops:0 */
13-
for (i = 0; i < len; i++) {
14-
data = angular.element(all[i]).data();
15-
scope = data.$scope || data.$isolateScope;
16-
if (scope && scope.hasOwnProperty(name)) {
17-
if ( !test[ scope.$id ] ) {
18-
test[ scope.$id ] = true;
19-
found.push(scope);
20-
}
21-
}
11+
/* global angular */
12+
/* eslint no-for-loops:0 */
13+
for (i = 0; i < len; i++) {
14+
data = angular.element(all[i]).data();
15+
scope = data.$scope || data.$isolateScope;
16+
if (scope && scope.hasOwnProperty(name)) {
17+
if ( !test[ scope.$id ] ) {
18+
test[ scope.$id ] = true;
19+
found.push(scope);
2220
}
23-
if (!found.length) {
24-
console.log('could not find any scopes with', name, 'property');
25-
} else {
26-
console.log('found', found.length, 'scopes with property', name);
27-
}
28-
return found;
21+
}
22+
}
23+
if (!found.length) {
24+
console.log('could not find any scopes with', name, 'property');
25+
} else {
26+
console.log('found', found.length, 'scopes with property', name);
2927
}
28+
return found;
29+
}
3030

31-
window.findScopeProperty = findScopeProperty;
31+
window.findScopeProperty = findScopeProperty;
3232
}(window));

ng-scope-size.js

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
*
2222
* object - the object whose size should be determined
2323
*/
24+
/* jshint -W073, -W071 */
2425
function sizeof(object){
2526

2627
// initialise the list of objects and size
@@ -33,17 +34,20 @@
3334
// determine the type of the object
3435
switch (typeof objects[index]) {
3536

36-
// the object is a boolean
37-
case 'boolean': size += 4; break;
37+
case 'boolean': {
38+
size += 4; break;
39+
}
3840

39-
// the object is a number
40-
case 'number': size += 8; break;
41+
case 'number': {
42+
size += 8; break;
43+
}
4144

42-
// the object is a string
43-
case 'string': size += 2 * objects[index].length; break;
45+
case 'string': {
46+
size += 2 * objects[index].length;
47+
break;
48+
}
4449

45-
// the object is a generic object
46-
case 'object':
50+
case 'object': {
4751

4852
// loop over the keys
4953
for (var key in objects[index]) {
@@ -70,6 +74,7 @@
7074
}
7175

7276
}
77+
}
7378

7479
}
7580

@@ -83,16 +88,16 @@
8388
// go through each element. Count watchers if it has scope or isolate scope
8489
/* eslint no-for-loops:0 */
8590
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-
}
91+
/* global angular */
92+
data = angular.element(all[i]).data();
93+
scope = data.$scope || data.$isolateScope;
94+
if (scope) {
95+
if ( !test[ scope.$id ] ) {
96+
test[ scope.$id ] = true;
97+
count += sizeof(scope);
98+
scopes += 1;
9599
}
100+
}
96101
}
97102
console.log(scopes, 'scopes have', count, 'bytes attached');
98103
return count;

0 commit comments

Comments
 (0)