🆕 Added Helpers
This commit is contained in:
parent
c69530abbd
commit
a4bbf9f9b8
22
src/functions/helpers.js
Normal file
22
src/functions/helpers.js
Normal file
@ -0,0 +1,22 @@
|
||||
//wrapper func for setstate that returns a promise
|
||||
export function setStateAsync(that, newState) {
|
||||
return new Promise((resolve) => {
|
||||
that.setState(newState, () => {
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
//wrapper for timeout that returns a promise
|
||||
export function timeout(ms) {
|
||||
return new Promise(resolve => {
|
||||
const timeoutID = setTimeout(() => {
|
||||
clearTimeout(timeoutID);
|
||||
resolve();
|
||||
}, ms)
|
||||
});
|
||||
};
|
||||
|
||||
export function pad(num, places = 2){
|
||||
return String(num).padStart(places, '0');
|
||||
};
|
||||
Loading…
Reference in New Issue
Block a user