Skip to content

Commit 447812b

Browse files
committedFeb 21, 2022
Expose the spinner interval as a getter
Fixes #202
1 parent c5026b7 commit 447812b

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed
 

‎index.d.ts

+7
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,13 @@ export interface Ora {
179179
*/
180180
indent: number;
181181

182+
/**
183+
The interval between each frame.
184+
185+
The interval is decided by the chosen spinner.
186+
*/
187+
readonly interval: number;
188+
182189
/**
183190
Start the spinner.
184191

‎index.js

+7-3
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ class Ora {
119119

120120
this.color = this.options.color;
121121
this.hideCursor = this.options.hideCursor !== false;
122-
this.interval = this.options.interval || this.spinner.interval || 100;
122+
this._interval = this.options.interval || this.spinner.interval || 100;
123123
this.stream = this.options.stream;
124124
this.id = undefined;
125125
this.isEnabled = typeof this.options.isEnabled === 'boolean' ? this.options.isEnabled : isInteractive({stream: this.stream});
@@ -149,10 +149,14 @@ class Ora {
149149

150150
_updateInterval(interval) {
151151
if (interval !== undefined) {
152-
this.interval = interval;
152+
this._interval = interval;
153153
}
154154
}
155155

156+
get interval() {
157+
return this._interval;
158+
}
159+
156160
get spinner() {
157161
return this._spinner;
158162
}
@@ -330,7 +334,7 @@ class Ora {
330334
}
331335

332336
this.render();
333-
this.id = setInterval(this.render.bind(this), this.interval);
337+
this.id = setInterval(this.render.bind(this), this._interval);
334338

335339
return this;
336340
}

0 commit comments

Comments
 (0)
Please sign in to comment.