How to use the polyfill-library.getPolyfillString 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 CultureHQ / polyfill-lambda / handler.js View on Github external
const makePolyfill = ({ uaString, cache }) => (
  getPolyfillString({ uaString, minify: cache, features, unknown: "polyfill" })
    .then(polyfill => {
      const polyfillHeaders = {
        ...headers,
        "Cache-Control": cache ? "max-age=31536000" : "no-cache",
        "Content-Type": "application/javascript;charset=utf-8"
      };

      return {
        status: 200,
        statusDescription: "OK",
        headers: Object.keys(polyfillHeaders).reduce(
          (accum, key) => ({ ...accum, [key]: [{ key, value: polyfillHeaders[key] }] }), {}
        ),
        body: polyfill
      };
    })
github Financial-Times / polyfill-service / server / routes / v3 / polyfill.js View on Github external
app.get(["/v3/polyfill.js", "/v3/polyfill.min.js"], async (request, response) => {
		const params = getPolyfillParameters(request);
		switch (params.version) {
			case latestVersion: {
				const bundle = await polyfillio.getPolyfillString(params);
				await respondWithBundle(response, params, bundle);
				break;
			}
			case "3.41.0": {
				const bundle = await polyfillio_3_41_0.getPolyfillString(params);
				await respondWithBundle(response, params, bundle);
				break;
			}
			case "3.40.0": {
				const bundle = await polyfillio_3_40_0.getPolyfillString(params);
				await respondWithBundle(response, params, bundle);
				break;
			}
			case "3.39.0": {
				const bundle = await polyfillio_3_39_0.getPolyfillString(params);
				await respondWithBundle(response, params, bundle);
github Financial-Times / polyfill-service / packages / polyfill-service / service / routes / docs.js View on Github external
return Promise.all(UAs.map(browser => {
				const opts = {
					features: PolyfillSet.fromQueryParam('default').get(),
					uaString: browser.family+'/'+browser.ver,
				};
				return Promise.all([
					polyfillservice.getPolyfillString(Object.assign({minify: true}, opts)),
					polyfillservice.getPolyfillString(Object.assign({minify: false}, opts))
				]).then(spread((minsrc, rawsrc) => {
						const item = {
							family: browser.family,
							ver: browser.ver,
							minsrc: minsrc,
							rawbytes: rawsrc.length,
							minbytes: minsrc.length
						};
						return new Promise(resolve => {
							zlib.gzip(item.minsrc, (err, gzipsrc) => {
								if (!err) {
									item.gzipbytes = gzipsrc.length;
								}
								resolve(item);
							});
						});