File tree Expand file tree Collapse file tree 8 files changed +30
-76
lines changed Expand file tree Collapse file tree 8 files changed +30
-76
lines changed Original file line number Diff line number Diff line change @@ -78,6 +78,11 @@ export class ActiveState extends BooleanState {
7878 }
7979}
8080
81+ // Initialize.
82+ const activeState = new ActiveState ();
83+
84+ // Deactivate the initial state.
85+ activeState .deactivate ();
8186```
8287
8388### ` EnumState `
@@ -149,7 +154,7 @@ numberedState.increment();
149154// Increment state by 5.
150155numberedState .increment (5 );
151156
152- // Reset state to 0..
157+ // Reset state to 0.
153158numberedState .reset ();
154159```
155160
Original file line number Diff line number Diff line change 11// Abstract.
22import { State } from "./state.abstract" ;
33/**
4- * @description Handles the boolean state.
4+ * @description Handles the ` boolean` type state.
55 * @export
66 * @abstract
77 * @class BooleanState
Original file line number Diff line number Diff line change 11// Abstract.
22import { State } from "./state.abstract" ;
33/**
4- * @description
4+ * @description Handles the `enum` type state.
55 * @export
66 * @abstract
77 * @class EnumState
@@ -23,7 +23,13 @@ export abstract class EnumState<
2323 constructor ( state : T , enumObject : EnumObject ) {
2424 super ( state ) ;
2525 }
26-
26+
27+ /**
28+ * @description Checks whether the state is of the specific enum.
29+ * @public
30+ * @param {T } state The specific enum to check whether state is.
31+ * @returns {boolean }
32+ */
2733 public is ( state : T ) {
2834 return super . state === state ;
2935 }
Original file line number Diff line number Diff line change 11/**
2- * @description
2+ * @description Manages the immutability states of `this` current instance.
33 * @export
44 * @abstract
55 * @class ImmutableState
@@ -26,7 +26,7 @@ export abstract class ImmutableState {
2626 }
2727
2828 /**
29- * @description
29+ * @description Checks whether `this` current instance is frozen.
3030 * @public
3131 * @returns {boolean }
3232 */
@@ -53,7 +53,7 @@ export abstract class ImmutableState {
5353 }
5454
5555 /**
56- * @description
56+ * @description Checks whether `this` current instance is sealed.
5757 * @public
5858 * @returns {boolean }
5959 */
Original file line number Diff line number Diff line change 11// Abstract.
22import { State } from "./state.abstract" ;
33/**
4- * @description
4+ * @description Handles and manages the `null` type state.
55 * @export
66 * @abstract
77 * @class NullState
@@ -19,7 +19,7 @@ export abstract class NullState extends State<null | undefined> {
1919 }
2020
2121 /**
22- * @description
22+ * @description Checks whether state is `null`.
2323 * @public
2424 * @returns {boolean }
2525 */
@@ -39,7 +39,7 @@ export abstract class NullState extends State<null | undefined> {
3939 }
4040
4141 /**
42- * @description
42+ * @description Removes the `null` state.
4343 * @public
4444 * @returns {this }
4545 */
@@ -48,64 +48,3 @@ export abstract class NullState extends State<null | undefined> {
4848 return this ;
4949 }
5050}
51-
52-
53-
54-
55-
56-
57-
58-
59-
60-
61-
62-
63-
64-
65-
66-
67-
68-
69-
70-
71-
72-
73-
74-
75-
76-
77-
78-
79-
80-
81-
82-
83-
84-
85-
86-
87-
88-
89-
90-
91- // export abstract class NullState<T> {
92- // private state: T | null;
93-
94- // constructor(initialState: T | null = null) {
95- // this.state = initialState;
96- // }
97-
98- // public get value(): T | null {
99- // return this.state;
100- // }
101-
102- // public set(value: T): this {
103- // this.state = value;
104- // return this;
105- // }
106-
107- // public clear(): this {
108- // this.state = null;
109- // return this;
110- // }
111- // }
Original file line number Diff line number Diff line change 11// Abstract.
22import { State } from "./state.abstract" ;
33/**
4- * @description Handles the number state.
4+ * @description Handles and manages the ` number` type state.
55 * @export
66 * @abstract
77 * @class NumberState
Original file line number Diff line number Diff line change 11// Abstract.
22import { ImmutableState } from "./immutable-state.abstract" ;
33/**
4- * @description
4+ * @description Common class for setting the state of `Type`.
55 * @export
66 * @abstract
77 * @class State
@@ -11,7 +11,7 @@ import { ImmutableState } from "./immutable-state.abstract";
1111 */
1212export abstract class State < Type > extends ImmutableState {
1313 /**
14- * @description
14+ * @description Returns the current state of `Type`.
1515 * @public
1616 * @readonly
1717 * @type {Type }
@@ -21,7 +21,7 @@ export abstract class State<Type> extends ImmutableState {
2121 }
2222
2323 /**
24- * @description
24+ * @description Privately stored state of `Type`.
2525 * @private
2626 * @type {Type }
2727 */
@@ -30,7 +30,7 @@ export abstract class State<Type> extends ImmutableState {
3030 /**
3131 * Creates an instance of parent class.
3232 * @constructor
33- * @param {Type } [initialState]
33+ * @param {Type } [initialState] Initial state of `Type`.
3434 */
3535 constructor ( initialState : Type ) {
3636 super ( ) ;
Original file line number Diff line number Diff line change @@ -18,3 +18,7 @@ export class ActiveState extends BooleanState {
1818 super . false ( ) ;
1919 }
2020}
21+
22+ const activeState = new ActiveState ( ) ;
23+
24+ activeState . deactivate ( ) ;
You can’t perform that action at this time.
0 commit comments