Skip to content

Commit

Permalink
Move delay() to lib
Browse files Browse the repository at this point in the history
  • Loading branch information
e1himself committed Dec 31, 2024
1 parent 69ea06b commit 6cbf6ac
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
8 changes: 1 addition & 7 deletions src/ModalTransitions.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from "react";

import { noop } from "./lib";
import { delay, noop } from "./lib";
import { useIsMounted } from "./useIsMounted";
import { useLatest } from "./useLatest";

Expand Down Expand Up @@ -103,9 +103,3 @@ export function ModalTransitions({ isOpen: shouldOpen, onClosed, transitionDurat
onClose,
});
}

function delay(ms: number): Promise<void> {
return new Promise((resolve) => {
setTimeout(resolve, ms);
});
}
6 changes: 6 additions & 0 deletions src/lib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ export function generateId() {
return `${new Date().getTime()}-${Math.random()}`;
}

export function delay(ms: number): Promise<void> {
return new Promise((resolve) => {
setTimeout(resolve, ms);
});
}

export function isEvent(value: unknown): value is Event {
return value instanceof Event;
}
Expand Down

0 comments on commit 6cbf6ac

Please sign in to comment.