This repository has been archived on 2022-03-12. You can view files and clone it, but cannot push or open issues or pull requests.

19 lines
614 B
JavaScript
Raw Normal View History

2021-04-02 02:24:13 +03:00
export const isnan = v => Number.isNaN(v);
export const isValidNumber = v => typeof v === 'number' && !Number.isNaN(v);
export const TEST_MIN_IF_NOT_NAN = (value, limit) =>
!isnan(limit) &&
((limit < 0 && value <= limit) || (limit >= 0 && value >= limit));
export const VEC_LEN_SQ = ({ x = 0, y = 0 } = {}) => x * x + y * y;
export const TEST_MAX_IF_NOT_NAN = (value, max) =>
!isnan(max) && ((max < 0 && value < max) || (max >= 0 && value > max));
export function fireAfterInterval(method, interval) {
if (!interval) {
method();
return null;
}
return setTimeout(() => method(), interval);
}