6
6
*/
7
7
function Set ( ) {
8
8
9
- var items = { } ;
9
+ let items = { } ;
10
10
11
11
this . add = function ( value ) {
12
12
if ( ! this . has ( value ) ) {
@@ -48,8 +48,8 @@ function Set() {
48
48
* @returns {number }
49
49
*/
50
50
this . sizeLegacy = function ( ) {
51
- var count = 0 ;
52
- for ( var key in items ) {
51
+ let count = 0 ;
52
+ for ( let key in items ) {
53
53
if ( items . hasOwnProperty ( key ) )
54
54
++ count ;
55
55
}
@@ -62,16 +62,16 @@ function Set() {
62
62
* @returns {Array }
63
63
*/
64
64
this . values = function ( ) {
65
- var values = [ ] ;
66
- for ( var i = 0 , keys = Object . keys ( items ) ; i < keys . length ; i ++ ) {
65
+ let values = [ ] ;
66
+ for ( let i = 0 , keys = Object . keys ( items ) ; i < keys . length ; i ++ ) {
67
67
values . push ( items [ keys [ i ] ] ) ;
68
68
}
69
69
return values ;
70
70
} ;
71
71
72
72
this . valuesLegacy = function ( ) {
73
- var values = [ ] ;
74
- for ( var key in items ) {
73
+ let values = [ ] ;
74
+ for ( let key in items ) {
75
75
if ( items . hasOwnProperty ( key ) ) {
76
76
values . push ( items [ key ] ) ;
77
77
}
@@ -84,26 +84,26 @@ function Set() {
84
84
} ;
85
85
86
86
this . union = function ( otherSet ) {
87
- var unionSet = new Set ( ) ; //{1}
87
+ let unionSet = new Set ( ) ; //{1}
88
88
89
- var values = this . values ( ) ; //{2}
90
- for ( var i = 0 ; i < values . length ; i ++ ) {
89
+ let values = this . values ( ) ; //{2}
90
+ for ( let i = 0 ; i < values . length ; i ++ ) {
91
91
unionSet . add ( values [ i ] ) ;
92
92
}
93
93
94
94
values = otherSet . values ( ) ; //{3}
95
- for ( var i = 0 ; i < values . length ; i ++ ) {
95
+ for ( let i = 0 ; i < values . length ; i ++ ) {
96
96
unionSet . add ( values [ i ] ) ;
97
97
}
98
98
99
99
return unionSet ;
100
100
} ;
101
101
102
102
this . intersection = function ( otherSet ) {
103
- var intersectionSet = new Set ( ) ; //{1}
103
+ let intersectionSet = new Set ( ) ; //{1}
104
104
105
- var values = this . values ( ) ;
106
- for ( var i = 0 ; i < values . length ; i ++ ) { //{2}
105
+ let values = this . values ( ) ;
106
+ for ( let i = 0 ; i < values . length ; i ++ ) { //{2}
107
107
if ( otherSet . has ( values [ i ] ) ) { //{3}
108
108
intersectionSet . add ( values [ i ] ) ; //{4}
109
109
}
@@ -113,10 +113,10 @@ function Set() {
113
113
} ;
114
114
115
115
this . difference = function ( otherSet ) {
116
- var differenceSet = new Set ( ) ; //{1}
116
+ let differenceSet = new Set ( ) ; //{1}
117
117
118
- var values = this . values ( ) ;
119
- for ( var i = 0 ; i < values . length ; i ++ ) { //{2}
118
+ let values = this . values ( ) ;
119
+ for ( let i = 0 ; i < values . length ; i ++ ) { //{2}
120
120
if ( ! otherSet . has ( values [ i ] ) ) { //{3}
121
121
differenceSet . add ( values [ i ] ) ; //{4}
122
122
}
@@ -130,8 +130,8 @@ function Set() {
130
130
if ( this . size ( ) > otherSet . size ( ) ) { //{1}
131
131
return false ;
132
132
} else {
133
- var values = this . values ( ) ;
134
- for ( var i = 0 ; i < values . length ; i ++ ) { //{2}
133
+ let values = this . values ( ) ;
134
+ for ( let i = 0 ; i < values . length ; i ++ ) { //{2}
135
135
if ( ! otherSet . has ( values [ i ] ) ) { //{3}
136
136
return false ; //{4}
137
137
}
0 commit comments