How to use the polyfill-library/package.json.version 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 / server / lib / get-polyfill-parameters.js View on Github external
"use strict";

const latestVersion = require("polyfill-library/package.json").version;
const featuresfromQueryParam = require("./features-from-query-parameter");

module.exports = function getPolyfillParameters(req = {}) {
	const query = req.query || {};
	const path = req.path || "";
	const { excludes = "", features = "default", rum, unknown = "polyfill", version, callback } = query;
	const uaString = query.ua || (req.headers && req.headers["user-agent"]) || (typeof req.get === "function" && req.get("User-Agent")) || "";
	const compression = query.compression !== "identity" ? query.compression : undefined;

	return {
		excludes: excludes ? excludes.split(",") : [],
		features: featuresfromQueryParam(features, query.flags),
		minify: path.endsWith(".min.js"),
		rum: Number.parseInt(rum, 10) === 1,
		stream: false,
		callback: /^[\w\.]+$/.test(callback || "") ? callback : false,
github Financial-Times / polyfill-service / packages / polyfill-service / server / lib / get-polyfill-parameters.js View on Github external
"use strict";

const latestVersion = require("polyfill-library/package.json").version;
const featuresfromQueryParam = require("./features-from-query-parameter");

module.exports = function getPolyfillParameters(req = {}) {
	const query = req.query || {};
	const path = req.path || "";
	const { excludes = "", features = "default", rum, unknown = "polyfill", version = latestVersion, callback } = query;
	const uaString = query.ua || (req.headers && req.headers["user-agent"]) || (typeof req.get === "function" && req.get("User-Agent")) || "";
	const compression = query.compression !== "identity" ? query.compression : undefined;

	return {
		excludes: excludes ? excludes.split(",") : [],
		features: featuresfromQueryParam(features, query.flags),
		minify: path.endsWith(".min.js"),
		rum: Number.parseInt(rum, 10) === 1,
		stream: false,
		callback: /^[\w\.]+$/.test(callback || "") ? callback : false,
github Financial-Times / polyfill-service / packages / polyfill-service / server / routes / v3 / polyfill.js View on Github external
"use strict";

const compressBundle = require("../../lib/compress-bundle");
const getPolyfillParameters = require("../../lib/get-polyfill-parameters");
const latestVersion = require("polyfill-library/package.json").version;
const PolyfillLibrary = require("polyfill-library");
const polyfillio_3_25_3 = require("polyfill-library-3.25.3");

async function respondWithBundle(response, params, bundle) {
	const file = await compressBundle(params.compression, bundle);
	const headers = {
		"Cache-Control": "public, s-maxage=31536000, max-age=604800, stale-while-revalidate=604800, stale-if-error=604800",
		"Content-Encoding": params.compression,
		"Content-Type": "application/javascript; charset=utf-8",
		"surrogate-key": "polyfill-service"
	};
	response.status(200);
	response.set(headers);
	response.send(file);
}
github Financial-Times / polyfill-service / packages / polyfill-service / server / lib / create-polyfill-library.js View on Github external
"use strict";

const fs = require("fs");
const path = require("path");
const tmpDir = require("os").tmpdir();
const untar = require("decompress");
const denodeify = require("denodeify");
const readFile = denodeify(fs.readFile);
const brotliDecompress = denodeify(require("iltorb").decompress);
const PolyfillLibrary = require("polyfill-library");
const latestVersion = require("polyfill-library/package.json").version;

module.exports = async function createPolyfillLibrary(version) {
	if (version === latestVersion) {
		return new PolyfillLibrary();
	}

	const polyfillDistTar = await brotliDecompress(await readFile(path.join(__dirname, `../polyfill-library-packages/${version}.tar.br`)));
	const polyfillsPath = path.join(tmpDir, version);
	await untar(polyfillDistTar, tmpDir);

	return new PolyfillLibrary(polyfillsPath);
};
github Financial-Times / polyfill-service / server / routes / v3 / polyfill.js View on Github external
"use strict";

const compressBundle = require("../../lib/compress-bundle");
const getPolyfillParameters = require("../../lib/get-polyfill-parameters");
const latestVersion = require("polyfill-library/package.json").version;
const polyfillio = require("polyfill-library");
const polyfillio_3_27_4 = require("polyfill-library-3.27.4");
const polyfillio_3_25_3 = require("polyfill-library-3.25.3");
const polyfillio_3_25_1 = require("polyfill-library-3.25.1");
const polyfillio_3_28_1 = require("polyfill-library-3.28.1");
const polyfillio_3_34_0 = require("polyfill-library-3.34.0");
const polyfillio_3_35_0 = require("polyfill-library-3.35.0");
const polyfillio_3_36_0 = require("polyfill-library-3.36.0");
const polyfillio_3_37_0 = require("polyfill-library-3.37.0");
const polyfillio_3_38_0 = require("polyfill-library-3.38.0");
const polyfillio_3_39_0 = require("polyfill-library-3.39.0");
const polyfillio_3_40_0 = require("polyfill-library-3.40.0");
const polyfillio_3_41_0 = require("polyfill-library-3.41.0");

async function respondWithBundle(response, params, bundle) {
	const file = await compressBundle(params.compression, bundle);