Skip to content

Commit 7fe7cf4

Browse files
committed
(#47) Refactored adapters
1 parent dabb0dc commit 7fe7cf4

File tree

2 files changed

+46
-46
lines changed

2 files changed

+46
-46
lines changed

lib/adapter/native.adapter.class.ts

+34-34
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ export class NativeAdapter {
4848
* @param {Point} p The new cursor position
4949
* @memberof NativeAdapter
5050
*/
51-
public async setMousePosition(p: Point): Promise<void> {
52-
await this.mouse.setMousePosition(p);
51+
public setMousePosition(p: Point): Promise<void> {
52+
return this.mouse.setMousePosition(p);
5353
}
5454

5555
/**
@@ -58,33 +58,33 @@ export class NativeAdapter {
5858
* @returns {Promise<Point>} Current cursor position
5959
* @memberof NativeAdapter
6060
*/
61-
public async currentMousePosition(): Promise<Point> {
62-
return await this.mouse.currentMousePosition();
61+
public currentMousePosition(): Promise<Point> {
62+
return this.mouse.currentMousePosition();
6363
}
6464

6565
/**
6666
* leftClick triggers a native left-click event via OS API
6767
*
6868
* @memberof NativeAdapter
6969
*/
70-
public async leftClick(): Promise<void> {
71-
await this.mouse.leftClick();
70+
public leftClick(): Promise<void> {
71+
return this.mouse.leftClick();
7272
}
7373

7474
/**
7575
* rightClick triggers a native right-click event via OS API
7676
*
7777
* @memberof NativeAdapter
7878
*/
79-
public async rightClick(): Promise<void> {
80-
await this.mouse.rightClick();
79+
public rightClick(): Promise<void> {
80+
return this.mouse.rightClick();
8181
}
8282

8383
/**
8484
* middleClick triggers a native middle-click event via OS API
8585
*/
86-
public async middleClick(): Promise<void> {
87-
await this.mouse.middleClick();
86+
public middleClick(): Promise<void> {
87+
return this.mouse.middleClick();
8888
}
8989

9090
/**
@@ -93,8 +93,8 @@ export class NativeAdapter {
9393
* @param {Button} btn The mouse button to press
9494
* @memberof NativeAdapter
9595
*/
96-
public async pressButton(btn: Button): Promise<void> {
97-
await this.mouse.pressButton(btn);
96+
public pressButton(btn: Button): Promise<void> {
97+
return this.mouse.pressButton(btn);
9898
}
9999

100100
/**
@@ -103,8 +103,8 @@ export class NativeAdapter {
103103
* @param {Button} btn The mouse button to release
104104
* @memberof NativeAdapter
105105
*/
106-
public async releaseButton(btn: Button): Promise<void> {
107-
await this.mouse.releaseButton(btn);
106+
public releaseButton(btn: Button): Promise<void> {
107+
return this.mouse.releaseButton(btn);
108108
}
109109

110110
/**
@@ -113,8 +113,8 @@ export class NativeAdapter {
113113
* @param {string} input The text to type
114114
* @memberof NativeAdapter
115115
*/
116-
public async type(input: string): Promise<void> {
117-
await this.keyboard.type(input);
116+
public type(input: string): Promise<void> {
117+
return this.keyboard.type(input);
118118
}
119119

120120
/**
@@ -123,8 +123,8 @@ export class NativeAdapter {
123123
* @param {Key[]} keys The keys to click
124124
* @memberof NativeAdapter
125125
*/
126-
public async click(...keys: Key[]): Promise<void> {
127-
await this.keyboard.click(...keys);
126+
public click(...keys: Key[]): Promise<void> {
127+
return this.keyboard.click(...keys);
128128
}
129129

130130
/**
@@ -133,8 +133,8 @@ export class NativeAdapter {
133133
* @param {Key[]} keys The Keys to press and hold
134134
* @memberof NativeAdapter
135135
*/
136-
public async pressKey(...keys: Key[]): Promise<void> {
137-
await this.keyboard.pressKey(...keys);
136+
public pressKey(...keys: Key[]): Promise<void> {
137+
return this.keyboard.pressKey(...keys);
138138
}
139139

140140
/**
@@ -143,8 +143,8 @@ export class NativeAdapter {
143143
* @param {Key[]} keys The Keys to release
144144
* @memberof NativeAdapter
145145
*/
146-
public async releaseKey(...keys: Key[]): Promise<void> {
147-
await this.keyboard.releaseKey(...keys);
146+
public releaseKey(...keys: Key[]): Promise<void> {
147+
return this.keyboard.releaseKey(...keys);
148148
}
149149

150150
/**
@@ -153,8 +153,8 @@ export class NativeAdapter {
153153
* @param {number} amount The amount of 'ticks' to scroll
154154
* @memberof NativeAdapter
155155
*/
156-
public async scrollUp(amount: number): Promise<void> {
157-
await this.mouse.scrollUp(amount);
156+
public scrollUp(amount: number): Promise<void> {
157+
return this.mouse.scrollUp(amount);
158158
}
159159

160160
/**
@@ -163,8 +163,8 @@ export class NativeAdapter {
163163
* @param {number} amount The amount of 'ticks' to scroll
164164
* @memberof NativeAdapter
165165
*/
166-
public async scrollDown(amount: number): Promise<void> {
167-
await this.mouse.scrollDown(amount);
166+
public scrollDown(amount: number): Promise<void> {
167+
return this.mouse.scrollDown(amount);
168168
}
169169

170170
/**
@@ -173,8 +173,8 @@ export class NativeAdapter {
173173
* @param {number} amount The amount of 'ticks' to scroll
174174
* @memberof NativeAdapter
175175
*/
176-
public async scrollLeft(amount: number): Promise<void> {
177-
await this.mouse.scrollLeft(amount);
176+
public scrollLeft(amount: number): Promise<void> {
177+
return this.mouse.scrollLeft(amount);
178178
}
179179

180180
/**
@@ -183,8 +183,8 @@ export class NativeAdapter {
183183
* @param {number} amount The amount of 'ticks' to scroll
184184
* @memberof NativeAdapter
185185
*/
186-
public async scrollRight(amount: number): Promise<void> {
187-
await this.mouse.scrollRight(amount);
186+
public scrollRight(amount: number): Promise<void> {
187+
return this.mouse.scrollRight(amount);
188188
}
189189

190190
/**
@@ -193,8 +193,8 @@ export class NativeAdapter {
193193
* @param {string} text The text to copy
194194
* @memberof NativeAdapter
195195
*/
196-
public async copy(text: string): Promise<void> {
197-
await this.clipboard.copy(text);
196+
public copy(text: string): Promise<void> {
197+
return this.clipboard.copy(text);
198198
}
199199

200200
/**
@@ -203,7 +203,7 @@ export class NativeAdapter {
203203
* @returns {Promise<string>} The clipboard text
204204
* @memberof NativeAdapter
205205
*/
206-
public async paste(): Promise<string> {
207-
return await this.clipboard.paste();
206+
public paste(): Promise<string> {
207+
return this.clipboard.paste();
208208
}
209209
}

lib/adapter/vision.adapter.class.ts

+12-12
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ export class VisionAdapter {
3030
* @returns {Promise<Image>} Image will contain screenshot data as well as dimensions
3131
* @memberof VisionAdapter
3232
*/
33-
public async grabScreen(): Promise<Image> {
34-
return await this.screen.grabScreen();
33+
public grabScreen(): Promise<Image> {
34+
return this.screen.grabScreen();
3535
}
3636

3737
/**
@@ -41,8 +41,8 @@ export class VisionAdapter {
4141
* @returns {Promise<Image>} Image will contain screenshot data of the specified region as well as dimensions
4242
* @memberof VisionAdapter
4343
*/
44-
public async grabScreenRegion(region: Region): Promise<Image> {
45-
return await this.screen.grabScreenRegion(region);
44+
public grabScreenRegion(region: Region): Promise<Image> {
45+
return this.screen.grabScreenRegion(region);
4646
}
4747

4848
/**
@@ -75,8 +75,8 @@ export class VisionAdapter {
7575
* @returns {Promise<number>} The main screen's width as reported by the OS
7676
* @memberof VisionAdapter
7777
*/
78-
public async screenWidth(): Promise<number> {
79-
return await this.screen.screenWidth();
78+
public screenWidth(): Promise<number> {
79+
return this.screen.screenWidth();
8080
}
8181

8282
/**
@@ -87,8 +87,8 @@ export class VisionAdapter {
8787
* @returns {Promise<number>} The main screen's height as reported by the OS
8888
* @memberof VisionAdapter
8989
*/
90-
public async screenHeight(): Promise<number> {
91-
return await this.screen.screenHeight();
90+
public screenHeight(): Promise<number> {
91+
return this.screen.screenHeight();
9292
}
9393

9494
/**
@@ -99,8 +99,8 @@ export class VisionAdapter {
9999
* @returns {Promise<Region>} The Region object the size of your main screen
100100
* @memberof VisionAdapter
101101
*/
102-
public async screenSize(): Promise<Region> {
103-
return await this.screen.screenSize();
102+
public screenSize(): Promise<Region> {
103+
return this.screen.screenSize();
104104
}
105105

106106
/**
@@ -110,7 +110,7 @@ export class VisionAdapter {
110110
* @param path The storage path
111111
* @memberof VisionAdapter
112112
*/
113-
public async saveImage(image: Image, path: string): Promise<void> {
114-
await (this.dataSink as ImageWriter).store(image, path);
113+
public saveImage(image: Image, path: string): Promise<void> {
114+
return (this.dataSink as ImageWriter).store(image, path);
115115
}
116116
}

0 commit comments

Comments
 (0)