File tree Expand file tree Collapse file tree 1 file changed +20
-28
lines changed Expand file tree Collapse file tree 1 file changed +20
-28
lines changed Original file line number Diff line number Diff line change @@ -25,38 +25,30 @@ import SessionState from "./SessionState";
25
25
* @param {Session|Object } [session] - another session. If passed, this session will clone its state.
26
26
* @constructor
27
27
*/
28
- function Session ( session ) {
29
- var self = this ;
30
-
31
- var states = [ ] ;
32
-
33
- if ( session ) {
34
- for ( let state of session . states ) {
35
- states . push ( new SessionState ( state ) ) ;
28
+ export default class Session {
29
+ constructor ( session ) {
30
+ this . states = [ ] ;
31
+ if ( session ) {
32
+ for ( let state of session . states ) {
33
+ this . states . push ( new SessionState ( state ) ) ;
34
+ }
36
35
}
36
+ Object . seal ( this ) ;
37
37
}
38
38
39
- Object . defineProperty ( self , "states" , {
40
- get : ( ) => states
41
- } ) ;
42
-
43
- self . mostRecentState = ( ) => {
44
- return states [ 0 ] ;
45
- } ;
39
+ mostRecentState ( ) {
40
+ return this . states [ 0 ] ;
41
+ }
46
42
47
- self . addState = ( state ) => {
48
- states . unshift ( state ) ;
49
- if ( states . length > ProtocolConstants . maximumSessionStatesPerIdentity ) {
50
- states . pop ( ) ;
43
+ addState ( state ) {
44
+ this . states . unshift ( state ) ;
45
+ if ( this . states . length > ProtocolConstants . maximumSessionStatesPerIdentity ) {
46
+ this . states . pop ( ) ;
51
47
}
52
- } ;
53
-
54
- self . removeState = ( state ) => {
55
- var index = states . indexOf ( state ) ;
56
- states . splice ( index , 1 ) ;
57
- } ;
48
+ }
58
49
59
- Object . freeze ( this ) ;
50
+ removeState ( state ) {
51
+ var index = this . states . indexOf ( state ) ;
52
+ this . states . splice ( index , 1 ) ;
53
+ }
60
54
}
61
-
62
- export default Session ;
You can’t perform that action at this time.
0 commit comments