1 |
|
2 | export const isnan = (v: unknown) => Number.isNaN(v);
|
3 |
|
4 |
|
5 | export const isValidNumber = (v: unknown) =>
|
6 | typeof v === 'number' && !Number.isNaN(v);
|
7 |
|
8 | export const TEST_MIN_IF_NOT_NAN = (value: number, limit: number): boolean =>
|
9 | !isnan(limit) &&
|
10 | ((limit < 0 && value <= limit) || (limit >= 0 && value >= limit));
|
11 | export const VEC_LEN_SQ = ({ x = 0, y = 0 } = {}) => x * x + y * y;
|
12 | export const TEST_MAX_IF_NOT_NAN = (value: number, max: number) =>
|
13 | !isnan(max) && ((max < 0 && value < max) || (max >= 0 && value > max));
|
14 |
|
15 | export function fireAfterInterval(
|
16 | method: () => void,
|
17 | interval?: number | boolean
|
18 | ) {
|
19 | if (!interval) {
|
20 | method();
|
21 | return null;
|
22 | }
|
23 | return setTimeout(() => method(), interval);
|
24 | }
|