blob: 821b3a413c427586c25aebfacb8b248f1d953f68 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
import { noop } from './utils.js';
export const is_client = typeof window !== 'undefined';
/** @type {() => number} */
export let now = is_client ? () => window.performance.now() : () => Date.now();
export let raf = is_client ? (cb) => requestAnimationFrame(cb) : noop;
// used internally for testing
/** @returns {void} */
export function set_now(fn) {
now = fn;
}
/** @returns {void} */
export function set_raf(fn) {
raf = fn;
}
|