Skip to content

Commit

Permalink
remove unused util functions
Browse files Browse the repository at this point in the history
  • Loading branch information
TwitchBronBron committed Oct 31, 2023
1 parent 3a96ae6 commit 4134930
Showing 1 changed file with 0 additions and 35 deletions.
35 changes: 0 additions & 35 deletions src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -381,41 +381,6 @@ class Util {
public escapeRegex(text: string) {
return text?.toString().replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');
}

/**
* Returns a function that generates a string of off+on chars for showing "animated" loading in text-based locations
* @param max the total number of chars to show
* @param offChar the char to show when that index is "off"
* @param onChar the char to show when that index is "on"
* @returns function that generates loading strings
*/
public createTextSpinner(max: number, offChar = '◦', onChar = '•') {
let current = 2;
const fullText = offChar.repeat(max).split('');
/**
* Generate the next text
* @param increment if false, will return the same value as last time
*/
return function spinner(increment = true) {
const text = [...fullText];
if (increment) {
current++;
}
text[current % max] = onChar;
return text.reverse().join('');
};
}

/**
* Set an interval
* @returns a function that can be called to clear the interval
*/
public setInterval(callback: () => any, duration: number) {
const handle = setInterval(callback, duration);
return () => {
clearInterval(handle);
};
}
}

const util = new Util();
Expand Down

0 comments on commit 4134930

Please sign in to comment.