mirror of https://github.com/sveltejs/svelte
parent
4bea83c972
commit
629bdbf3fa
@ -1,16 +1,18 @@
|
|||||||
import { noop } from './utils';
|
import { noop } from './utils';
|
||||||
|
|
||||||
export const is_client = typeof window !== 'undefined';
|
export const is_client = typeof window !== 'undefined';
|
||||||
|
/** @type {() => number} */
|
||||||
export let now: () => number = is_client ? () => window.performance.now() : () => Date.now();
|
export let now = is_client ? () => window.performance.now() : () => Date.now();
|
||||||
|
|
||||||
export let raf = is_client ? (cb) => requestAnimationFrame(cb) : noop;
|
export let raf = is_client ? (cb) => requestAnimationFrame(cb) : noop;
|
||||||
|
|
||||||
// used internally for testing
|
// used internally for testing
|
||||||
|
/** @returns {void} */
|
||||||
export function set_now(fn) {
|
export function set_now(fn) {
|
||||||
now = fn;
|
now = fn;
|
||||||
}
|
}
|
||||||
|
/** @returns {void} */
|
||||||
export function set_raf(fn) {
|
export function set_raf(fn) {
|
||||||
raf = fn;
|
raf = fn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in new issue