How to use the polyfill-library/lib/UA.getBaselines function in polyfill-library

To help you get started, we’ve selected a few polyfill-library examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Financial-Times / polyfill-service / packages / polyfill-service / service / routes / docs.js View on Github external
appversion: appVersion,
		pageName: ((Number.isInteger(Number.parseInt(req.params[0], 10)) ? req.params[1] : req.params[0]) || 'index').replace(/\/$/, ''),
		rumEnabled: !!process.env.RUM_MYSQL_DSN,
		host: process.env.HOSTNAME || req.protocol + '://' + req.get('host') || 'https://polyfill.io'
	}, docsData);

	if (locals.pageName === 'usage') {

		// Set the ttl to one hour for the usage page so the graphs are
		// updated more frequently, overriding the default cache-control
		// behaviour set in index.js
		const one_hour = 60 * 60;
		const one_week = one_hour * 24 * 7;
		res.set('Cache-Control', 'public, max-age=' + one_hour + ', stale-while-revalidate=' + one_week + ', stale-if-error=' + one_week);
	} else if (locals.pageName === 'contributing/authoring-polyfills') {
		locals.baselines = require('polyfill-library/lib/UA').getBaselines();
	}

	template(locals.pageName)
		.then(templFn => res.send(templFn(locals)))
		.catch(err => {
			console.log(err);
			next();
		})
	;
}