Skip to content

Commit 8e7ec97

Browse files
Move option to the interface (#32)
1 parent adf0c90 commit 8e7ec97

File tree

2 files changed

+21
-17
lines changed

2 files changed

+21
-17
lines changed

lib/device.ts

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,25 @@ export enum ConnectionStatus {
100100
RECONNECTING = "RECONNECTING",
101101
}
102102

103+
export interface FlashOptions {
104+
/**
105+
* True to use a partial flash where possible, false to force a full flash.
106+
*/
107+
partial: boolean;
108+
/**
109+
* A progress callback. Called with undefined when the process is complete or has failed.
110+
*
111+
* Requesting a partial flash doesn't guarantee one is performed. Partial flashes are avoided
112+
* if too many blocks have changed and failed partial flashes are retried as full flashes.
113+
* The partial parameter reports the flash type currently in progress.
114+
*/
115+
progress: (percentage: number | undefined, partial: boolean) => void;
116+
/**
117+
* Smallest possible progress increment to limit callback rate.
118+
*/
119+
minimumProgressIncrement?: number;
120+
}
121+
103122
export class FlashDataError extends Error {}
104123

105124
export type FlashDataSource = (
@@ -201,23 +220,7 @@ export interface DeviceConnection
201220
* @param dataSource The data to use.
202221
* @param options Flash options and progress callback.
203222
*/
204-
flash?(
205-
dataSource: FlashDataSource,
206-
options: {
207-
/**
208-
* True to use a partial flash where possible, false to force a full flash.
209-
*/
210-
partial: boolean;
211-
/**
212-
* A progress callback. Called with undefined when the process is complete or has failed.
213-
*
214-
* Requesting a partial flash doesn't guarantee one is performed. Partial flashes are avoided
215-
* if too many blocks have changed and failed partial flashes are retried as full flashes.
216-
* The partial parameter reports the flash type currently in progress.
217-
*/
218-
progress: (percentage: number | undefined, partial: boolean) => void;
219-
},
220-
): Promise<void>;
223+
flash?(dataSource: FlashDataSource, options: {}): Promise<void>;
221224

222225
/**
223226
* Disconnect from the device.

lib/usb.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import {
1616
FlashDataError,
1717
FlashDataSource,
1818
FlashEvent,
19+
FlashOptions,
1920
SerialDataEvent,
2021
SerialErrorEvent,
2122
SerialResetEvent,

0 commit comments

Comments
 (0)