Debian Codegraph @

extensions/VisualEditor/lib/ve/src/ve.js

raw symbols SCIP
1 /*!
2 * VisualEditor namespace.
3 *
4 * @copyright See AUTHORS.txt
5 */
6
7 /**
8 * Namespace for all VisualEditor classes, static methods and static properties.
9 *
10 * @namespace ve
11 */
12 window.ve = {};
13
14 /**
15 * Get the current time, measured in milliseconds since January 1, 1970 (UTC).
16 *
17 * @return {number} Current time, monotonic in modern browsers (via Performance Timeline API)
18 */
19 ve.now = function () {
20 // Based on `mw.now` in MediaWiki core.
21 // Optimisation: Cache and re-use the chosen implementation.
22 // Optimisation: Avoid startup overhead by re-defining on first call instead of IIFE.
23 const perf = window.performance;
24 const navStart = perf && perf.timing && perf.timing.navigationStart;
25 ve.now = navStart && perf.now ?
26 function () {
27 return navStart + perf.now();
28 } : Date.now;
29
30 return ve.now();
31 };