All files / src ve.js

100% Statements 7/7
85.71% Branches 6/7
100% Functions 2/2
100% Lines 7/7

Press n or j to go to the next uncovered block, b, p or k for the previous block.

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