aboutsummaryrefslogtreecommitdiffstats
path: root/packages/utils/src/interval_utils.ts
diff options
context:
space:
mode:
authorFabio Berger <me@fabioberger.com>2018-01-30 20:21:01 +0800
committerFabio Berger <me@fabioberger.com>2018-01-30 20:21:01 +0800
commit93a5b3f457c1211676296840c285759007a55500 (patch)
treed1682b657c207f447748e08550095bafc79b6997 /packages/utils/src/interval_utils.ts
parent4242176d291f54212797de9f5df80b1346724ebb (diff)
downloaddexon-sol-tools-93a5b3f457c1211676296840c285759007a55500.tar
dexon-sol-tools-93a5b3f457c1211676296840c285759007a55500.tar.gz
dexon-sol-tools-93a5b3f457c1211676296840c285759007a55500.tar.bz2
dexon-sol-tools-93a5b3f457c1211676296840c285759007a55500.tar.lz
dexon-sol-tools-93a5b3f457c1211676296840c285759007a55500.tar.xz
dexon-sol-tools-93a5b3f457c1211676296840c285759007a55500.tar.zst
dexon-sol-tools-93a5b3f457c1211676296840c285759007a55500.zip
Fix prettier
Diffstat (limited to 'packages/utils/src/interval_utils.ts')
-rw-r--r--packages/utils/src/interval_utils.ts66
1 files changed, 33 insertions, 33 deletions
diff --git a/packages/utils/src/interval_utils.ts b/packages/utils/src/interval_utils.ts
index ebecc7015..65e51677b 100644
--- a/packages/utils/src/interval_utils.ts
+++ b/packages/utils/src/interval_utils.ts
@@ -1,37 +1,37 @@
import * as _ from 'lodash';
export const intervalUtils = {
- setAsyncExcludingInterval(fn: () => Promise<void>, intervalMs: number, onError: (err: Error) => void) {
- let locked = false;
- const intervalId = setInterval(async () => {
- if (locked) {
- return;
- } else {
- locked = true;
- try {
- await fn();
- } catch (err) {
- onError(err);
- }
- locked = false;
- }
- }, intervalMs);
- return intervalId;
- },
- clearAsyncExcludingInterval(intervalId: NodeJS.Timer): void {
- clearInterval(intervalId);
- },
- setInterval(fn: () => void, intervalMs: number, onError: (err: Error) => void) {
- const intervalId = setInterval(() => {
- try {
- fn();
- } catch (err) {
- onError(err);
- }
- }, intervalMs);
- return intervalId;
- },
- clearInterval(intervalId: NodeJS.Timer): void {
- clearInterval(intervalId);
- },
+ setAsyncExcludingInterval(fn: () => Promise<void>, intervalMs: number, onError: (err: Error) => void) {
+ let locked = false;
+ const intervalId = setInterval(async () => {
+ if (locked) {
+ return;
+ } else {
+ locked = true;
+ try {
+ await fn();
+ } catch (err) {
+ onError(err);
+ }
+ locked = false;
+ }
+ }, intervalMs);
+ return intervalId;
+ },
+ clearAsyncExcludingInterval(intervalId: NodeJS.Timer): void {
+ clearInterval(intervalId);
+ },
+ setInterval(fn: () => void, intervalMs: number, onError: (err: Error) => void) {
+ const intervalId = setInterval(() => {
+ try {
+ fn();
+ } catch (err) {
+ onError(err);
+ }
+ }, intervalMs);
+ return intervalId;
+ },
+ clearInterval(intervalId: NodeJS.Timer): void {
+ clearInterval(intervalId);
+ },
};